From: tonci.damjanic@... Date: 2015-01-22T09:22:24+00:00 Subject: [ruby-core:67753] [ruby-trunk - Bug #10735] Memory leak in openssl ossl_pkey_sign Issue #10735 has been updated by Ton��i Damjani��. Confirming the same with the current Ruby 2.2 (ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin14]): ~~~ {:count=>5, :heap_allocated_pages=>74, :heap_sorted_length=>75, :heap_allocatable_pages=>0, :heap_available_slots=>30164, :heap_live_slots=>29039, :heap_free_slots=>1125, :heap_final_slots=>0, :heap_marked_slots=>8424, :heap_swept_slots=>9725, :heap_eden_pages=>73, :heap_tomb_pages=>1, :total_allocated_pages=>74, :total_freed_pages=>0, :total_allocated_objects=>52920, :total_freed_objects=>23881, :malloc_increase_bytes=>275968, :malloc_increase_bytes_limit=>16777216, :minor_gc_count=>3, :major_gc_count=>2, :remembered_wb_unprotected_objects=>161, :remembered_wb_unprotected_objects_limit=>278, :old_objects=>8196, :old_objects_limit=>10808, :oldmalloc_increase_bytes=>276352, :oldmalloc_increase_bytes_limit=>16777216} Memory 10188KB ~~~ 100k iterations later: ~~~ {:count=>20, :heap_allocated_pages=>74, :heap_sorted_length=>75, :heap_allocatable_pages=>0, :heap_available_slots=>30164, :heap_live_slots=>29999, :heap_free_slots=>165, :heap_final_slots=>0, :heap_marked_slots=>9656, :heap_swept_slots=>406, :heap_eden_pages=>74, :heap_tomb_pages=>0, :total_allocated_pages=>74, :total_freed_pages=>0, :total_allocated_objects=>353037, :total_freed_objects=>323038, :malloc_increase_bytes=>24000, :malloc_increase_bytes_limit=>16777216, :minor_gc_count=>18, :major_gc_count=>2, :remembered_wb_unprotected_objects=>227, :remembered_wb_unprotected_objects_limit=>278, :old_objects=>9331, :old_objects_limit=>10808, :oldmalloc_increase_bytes=>1983872, :oldmalloc_increase_bytes_limit=>16777216} Memory 25340KB ~~~ ---------------------------------------- Bug #10735: Memory leak in openssl ossl_pkey_sign https://bugs.ruby-lang.org/issues/10735#change-51180 * Author: Viktor Vasilev * Status: Assigned * Priority: Normal * Assignee: openssl * ruby -v: ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux] * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN ---------------------------------------- Similar to the memory leak fixed in https://bugs.ruby-lang.org/issues/9743 there is an issue with ossl_pkey_sign. The ruby heap usage reported through GC.stat remains very stable, while the process heap grows linearly with the number of OpenSSL::PKey::RSA sign calls. The documentation at https://www.openssl.org/docs/crypto/EVP_SignInit.html (similar to EVP_VerifyInit) mentions that not disposing the context causes a leak. To reproduce: https://gist.github.com/viktorium/f032cdc8906f43dac94e A patch with a fix very similar to issue #9743: https://gist.github.com/viktorium/b466b72c83d2ab90182c -- https://bugs.ruby-lang.org/