1The following is an example of rb_malloc.d. 2 3WARNING: This script is not 100% accurate; This prints graphical 4representations of libc malloc() byte distributions by "recent" Ruby operation, 5which we hope will be usually correct. This is an experimental script that may 6be improved over time. 7 8Here we can see it running on Code/Ruby/func_abc.rb 9 10# rb_malloc.d -c ./func_abc.rb 11Tracing... Hit Ctrl-C to end. 12Function A 13Function B 14Function C 15Ruby malloc byte distributions by recent Ruby operation, 16 func_abc.rb, method, Object::print 17 value ------------- Distribution ------------- count 18 1 | 0 19 2 |@@@@@@@@@@@@@@@@@@@@ 1 20 4 | 0 21 8 | 0 22 16 |@@@@@@@@@@@@@@@@@@@@ 1 23 32 | 0 24 25 func_abc.rb, method, Module::method_added 26 value ------------- Distribution ------------- count 27 8 | 0 28 16 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2 29 32 | 0 30 31 ., objnew, fatal 32 value ------------- Distribution ------------- count 33 1 | 0 34 2 |@ 1 35 4 |@ 1 36 8 |@@@ 2 37 16 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 22 38 32 |@@@@@@ 5 39 64 | 0 40 41 func_abc.rb, method, IO::write 42 value ------------- Distribution ------------- count 43 2048 | 0 44 4096 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1 45 8192 | 0 46 47 ., objnew, SystemStackError 48 value ------------- Distribution ------------- count 49 1 | 0 50 2 | 3 51 4 |@@@@ 32 52 8 |@@ 15 53 16 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 279 54 32 |@@@ 30 55 64 | 2 56 128 | 0 57 58 ., objnew, NoMemoryError 59 value ------------- Distribution ------------- count 60 1 | 0 61 2 |@ 3 62 4 |@@@ 17 63 8 |@@@@@@ 37 64 16 |@@@@@@@@@@@@@@@@@@@@@@@@ 146 65 32 |@@ 13 66 64 | 2 67 128 |@@@ 20 68 256 | 0 69 512 | 0 70 1024 | 1 71 2048 | 0 72 73 ., objnew, ThreadGroup 74 value ------------- Distribution ------------- count 75 1 | 0 76 2 | 8 77 4 |@@@ 224 78 8 |@ 93 79 16 |@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1806 80 32 |@@@@@@@@ 496 81 64 | 3 82 128 | 2 83 256 | 0 84 512 | 1 85 1024 | 0 86 87 ., objnew, Object 88 value ------------- Distribution ------------- count 89 1 | 0 90 2 | 35 91 4 |@@@ 291 92 8 |@@@ 300 93 16 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2679 94 32 |@@ 215 95 64 | 7 96 128 | 0 97 98 ruby, startup, - 99 value ------------- Distribution ------------- count 100 1 | 0 101 2 |@ 10 102 4 |@@@ 34 103 8 |@@@ 38 104 16 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 409 105 32 |@@ 30 106 64 | 1 107 128 | 0 108 256 | 0 109 512 | 0 110 1024 | 2 111 2048 | 0 112 4096 | 0 113 8192 | 0 114 16384 | 0 115 32768 | 0 116 65536 | 0 117 131072 | 1 118 262144 | 0 119 120 121