mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Fix memory leak when copying ST tables
st_copy allocates a st_table, which is not needed for hashes since it is allocated by VWA and embedded, so this causes a memory leak. The following script demonstrates the issue: ```ruby 20.times do 100_000.times do {a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7, h: 8, i: 9} end puts `ps -o rss= -p #{$$}` end ```
This commit is contained in:
parent
df2b3a2998
commit
f0d08d11dc
Notes:
git
2023-06-29 15:17:09 +00:00
5 changed files with 43 additions and 23 deletions
|
@ -109,6 +109,8 @@ nonempty_memcpy(void *dest, const void *src, size_t n)
|
|||
#define st_add_direct rb_parser_st_add_direct
|
||||
#undef st_insert2
|
||||
#define st_insert2 rb_parser_st_insert2
|
||||
#undef st_replace
|
||||
#define st_replace rb_parser_st_replace
|
||||
#undef st_copy
|
||||
#define st_copy rb_parser_st_copy
|
||||
#undef st_delete_safe
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue