Skip to content

Instantly share code, notes, and snippets.

@spajus
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spajus/9363703 to your computer and use it in GitHub Desktop.
Save spajus/9363703 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'glusterfs'
50.times do
volume = GlusterFS::Volume.new('dist-volume')
volume.mount('distfs')
volume.unmount
_, size = `ps ax -o pid,rss | grep -E "^[[:space:]]*#{$$}"`.strip.split.map(&:to_i)
puts "Mem usage: #{size}"
end
[root@localhost vagrant]# valgrind --leak-check=full ruby leaks.rb
==14995== Memcheck, a memory error detector
==14995== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==14995== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==14995== Command: ruby leaks.rb
==14995==
==14995== Conditional jump or move depends on uninitialised value(s)
==14995== at 0x4EB214F: mark_current_machine_context (gc.c:769)
==14995== by 0x4EB2C0E: gc_marks (gc.c:2931)
==14995== by 0x4EB41D7: newobj (gc.c:2071)
==14995== by 0x4EB4667: rb_node_newnode (gc.c:696)
==14995== by 0x4EFE589: arg_append_gen (parse.y:8139)
==14995== by 0x4EFE640: node_assign_gen (parse.y:8813)
==14995== by 0x4F10056: ruby_yyparse (parse.y:1941)
==14995== by 0x4F101B8: yycompile0 (parse.y:5337)
==14995== by 0x4FD4B18: rb_suppress_tracing (vm_trace.c:364)
==14995== by 0x4EF8491: rb_parser_compile_file (parse.y:5369)
==14995== by 0x4F54730: load_file_internal (ruby.c:1710)
==14995== by 0x4E9ACBA: rb_ensure (eval.c:813)
==14995==
==14995== Conditional jump or move depends on uninitialised value(s)
==14995== at 0x4EB2155: mark_current_machine_context (gc.c:769)
==14995== by 0x4EB2C0E: gc_marks (gc.c:2931)
==14995== by 0x4EB41D7: newobj (gc.c:2071)
==14995== by 0x4EB4667: rb_node_newnode (gc.c:696)
==14995== by 0x4EFE589: arg_append_gen (parse.y:8139)
==14995== by 0x4EFE640: node_assign_gen (parse.y:8813)
==14995== by 0x4F10056: ruby_yyparse (parse.y:1941)
==14995== by 0x4F101B8: yycompile0 (parse.y:5337)
==14995== by 0x4FD4B18: rb_suppress_tracing (vm_trace.c:364)
==14995== by 0x4EF8491: rb_parser_compile_file (parse.y:5369)
==14995== by 0x4F54730: load_file_internal (ruby.c:1710)
==14995== by 0x4E9ACBA: rb_ensure (eval.c:813)
==14995==
==14995== Conditional jump or move depends on uninitialised value(s)
==14995== at 0x4EB216C: mark_current_machine_context (gc.c:770)
==14995== by 0x4EB2C0E: gc_marks (gc.c:2931)
==14995== by 0x4EB41D7: newobj (gc.c:2071)
==14995== by 0x4EB4667: rb_node_newnode (gc.c:696)
==14995== by 0x4EFE589: arg_append_gen (parse.y:8139)
==14995== by 0x4EFE640: node_assign_gen (parse.y:8813)
==14995== by 0x4F10056: ruby_yyparse (parse.y:1941)
==14995== by 0x4F101B8: yycompile0 (parse.y:5337)
==14995== by 0x4FD4B18: rb_suppress_tracing (vm_trace.c:364)
==14995== by 0x4EF8491: rb_parser_compile_file (parse.y:5369)
==14995== by 0x4F54730: load_file_internal (ruby.c:1710)
==14995== by 0x4E9ACBA: rb_ensure (eval.c:813)
==14995==
==14995== Conditional jump or move depends on uninitialised value(s)
==14995== at 0x4EB2192: mark_current_machine_context (gc.c:778)
==14995== by 0x4EB2C0E: gc_marks (gc.c:2931)
==14995== by 0x4EB41D7: newobj (gc.c:2071)
==14995== by 0x4EB4667: rb_node_newnode (gc.c:696)
==14995== by 0x4EFE589: arg_append_gen (parse.y:8139)
==14995== by 0x4EFE640: node_assign_gen (parse.y:8813)
==14995== by 0x4F10056: ruby_yyparse (parse.y:1941)
==14995== by 0x4F101B8: yycompile0 (parse.y:5337)
==14995== by 0x4FD4B18: rb_suppress_tracing (vm_trace.c:364)
==14995== by 0x4EF8491: rb_parser_compile_file (parse.y:5369)
==14995== by 0x4F54730: load_file_internal (ruby.c:1710)
==14995== by 0x4E9ACBA: rb_ensure (eval.c:813)
...skip...
==14995==
==14995== 89,440 bytes in 5 blocks are possibly lost in loss record 18,094 of 18,121
==14995== at 0x4C2677B: calloc (vg_replace_malloc.c:593)
==14995== by 0xE4DC132: __gf_calloc (in /usr/lib64/libglusterfs.so.0.0.0)
==14995== by 0xE4DC4EE: mem_pool_new_fn (in /usr/lib64/libglusterfs.so.0.0.0)
==14995== by 0xE29A892: rpc_clnt_new (in /usr/lib64/libgfrpc.so.0.0.0)
==14995== by 0xDE661F7: glfs_mgmt_init (in /usr/lib64/libgfapi.so.0.0.0)
==14995== by 0xDE65935: glfs_volumes_init (in /usr/lib64/libgfapi.so.0.0.0)
==14995== by 0xDE65D2F: glfs_init_common (in /usr/lib64/libgfapi.so.0.0.0)
==14995== by 0xDE65DA8: glfs_init (in /usr/lib64/libgfapi.so.0.0.0)
==14995== by 0xDC5CDAB: ffi_call_unix64 (in /usr/lib64/libffi.so.5.0.6)
==14995== by 0xDC5CB33: ffi_call (in /usr/lib64/libffi.so.5.0.6)
==14995== by 0xDA45610: rbffi_CallFunction (Call.c:378)
==14995== by 0xDA45F05: custom_trampoline (MethodHandle.c:232)
==14995==
==14995== 119,760 (48 direct, 119,712 indirect) bytes in 1 blocks are definitely lost in loss
record 18,096 of 18,121
==14995== at 0x4C279EE: malloc (vg_replace_malloc.c:270)
==14995== by 0x4EB4977: vm_xmalloc (gc.c:3523)
==14995== by 0x4F5EBA3: st_init_table_with_size (st.c:247)
==14995== by 0x4E9E393: Init_load (load.c:1168)
==14995== by 0x4EBB839: rb_call_inits (inits.c:50)
==14995== by 0x4E9C084: ruby_setup (eval.c:57)
==14995== by 0x4E9C0B8: ruby_init (eval.c:73)
==14995== by 0x4008D5: main (main.c:35)
==14995==
==14995== 237,742 bytes in 58 blocks are definitely lost in loss record 18,097 of 18,121
==14995== at 0x4C279EE: malloc (vg_replace_malloc.c:270)
==14995== by 0x4EB4977: vm_xmalloc (gc.c:3523)
==14995== by 0x4F65AC4: str_new (string.c:410)
==14995== by 0x4F66105: rb_usascii_str_new (string.c:433)
==14995== by 0x4EA9085: rb_file_expand_path (file.c:3318)
==14995== by 0x4EA90F4: rb_file_s_expand_path (file.c:3350)
==14995== by 0x4FB8688: vm_call_cfunc_with_frame (vm_insnhelper.c:1480)
==14995== by 0x4FBCB2C: vm_exec_core (insns.def:1017)
==14995== by 0x4FC2A9A: vm_exec (vm.c:1201)
==14995== by 0x4FC6CEC: rb_yield (vm.c:679)
==14995== by 0x4E66D04: rb_ary_collect (array.c:2541)
==14995== by 0x4FB8688: vm_call_cfunc_with_frame (vm_insnhelper.c:1480)
==14995==
==14995== LEAK SUMMARY:
==14995== definitely lost: 811,391 bytes in 4,611 blocks
==14995== indirectly lost: 1,030,537 bytes in 18,593 blocks
==14995== possibly lost: 117,385 bytes in 73 blocks
==14995== still reachable: 224,234,607 bytes in 10,285 blocks
==14995== suppressed: 0 bytes in 0 blocks
==14995== Reachable blocks (those to which a pointer was found) are not shown.
==14995== To see them, rerun with: --leak-check=full --show-reachable=yes
==14995==
==14995== For counts of detected and suppressed errors, rerun with: -v
==14995== Use --track-origins=yes to see where uninitialised values come from
==14995== ERROR SUMMARY: 56447 errors from 1726 contexts (suppressed: 66 from 9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment