memprof 0.3.3 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +118 -0
- data/ext/memprof.c +5 -1
- data/lib/memprof/middleware.rb +4 -0
- data/memprof.gemspec +1 -1
- metadata +4 -4
- data/README +0 -72
data/README.rdoc
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
= memprof (c) Joe Damato @joedamato http://timetobleed.com
|
|
2
|
+
|
|
3
|
+
Memprof is a Ruby level memory profiler that can help you find reference leaks in your application.
|
|
4
|
+
Memprof can also do very lightweight function call tracing to help you figure out which system calls, and library calls your code causes.
|
|
5
|
+
|
|
6
|
+
== Installing
|
|
7
|
+
|
|
8
|
+
gem install memprof
|
|
9
|
+
|
|
10
|
+
== Usage
|
|
11
|
+
|
|
12
|
+
== Memory Tracking
|
|
13
|
+
|
|
14
|
+
== Blocks (memory tracking)
|
|
15
|
+
|
|
16
|
+
Memprof.track {
|
|
17
|
+
100.times{ "abc" }
|
|
18
|
+
100.times{ 1.23 + 1 }
|
|
19
|
+
100.times{ Module.new }
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
Outputs:
|
|
23
|
+
|
|
24
|
+
100 file.rb:2:String
|
|
25
|
+
100 file.rb:3:Float
|
|
26
|
+
100 file.rb:4:Module
|
|
27
|
+
|
|
28
|
+
== Rails requests (memory tracking)
|
|
29
|
+
|
|
30
|
+
Use the Memprof::Middleware
|
|
31
|
+
|
|
32
|
+
== Dump objects
|
|
33
|
+
|
|
34
|
+
Memprof.dump {
|
|
35
|
+
"hello" + "world"
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
Outputs:
|
|
39
|
+
|
|
40
|
+
{
|
|
41
|
+
"_id": "0x19c610",
|
|
42
|
+
"file": "file.rb",
|
|
43
|
+
"line": 2,
|
|
44
|
+
"type": "string",
|
|
45
|
+
"class": "0x1ba7f0",
|
|
46
|
+
"class_name": "String",
|
|
47
|
+
"length": 10,
|
|
48
|
+
"data": "helloworld"
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
You can dump any Ruby object you want.
|
|
52
|
+
|
|
53
|
+
== Dumping the entire heap
|
|
54
|
+
|
|
55
|
+
Memprof.dump_all("file.json")
|
|
56
|
+
|
|
57
|
+
This will dump out every single live object as json to /tmp/file.json
|
|
58
|
+
|
|
59
|
+
== Less elegant tracking usage:
|
|
60
|
+
|
|
61
|
+
require 'memprof'
|
|
62
|
+
Memprof.start
|
|
63
|
+
|
|
64
|
+
# ruby code
|
|
65
|
+
|
|
66
|
+
Memprof.stats
|
|
67
|
+
|
|
68
|
+
# more ruby code
|
|
69
|
+
|
|
70
|
+
Memprof.stats
|
|
71
|
+
Memprof.stop
|
|
72
|
+
|
|
73
|
+
The above code will output 2 summaries, allowing you to compare which objects were
|
|
74
|
+
destroyed and which are still around.
|
|
75
|
+
|
|
76
|
+
Memprof.stats also takes an (optional) file name to write the output to a file.
|
|
77
|
+
|
|
78
|
+
== Function call tracing
|
|
79
|
+
|
|
80
|
+
This system is under development and the API may change without warning.
|
|
81
|
+
|
|
82
|
+
You can use the middleware Memprof::Tracer to output function tracing and request information for
|
|
83
|
+
each request that comes in to your app.
|
|
84
|
+
|
|
85
|
+
== Compatibility
|
|
86
|
+
|
|
87
|
+
You must have debug symbols installed or a an unstripped version of Ruby.
|
|
88
|
+
|
|
89
|
+
To install debug symbols on Debian-like systems:
|
|
90
|
+
|
|
91
|
+
apt-get install libruby1.8-dbg
|
|
92
|
+
|
|
93
|
+
Not supporting:
|
|
94
|
+
* OSX default Ruby
|
|
95
|
+
* Stripped Ruby binaries without debug symbols
|
|
96
|
+
* Any and all Windows Ruby builds
|
|
97
|
+
* Ruby 1.9+ on all systems
|
|
98
|
+
* 32bit systems
|
|
99
|
+
|
|
100
|
+
Supporting:
|
|
101
|
+
* Linux (enable-shared AND disable-shared):
|
|
102
|
+
* x86_64 builds of Ruby Enterprise Edition 1.8.6/1.8.7
|
|
103
|
+
* x86_64 builds of MRI Ruby
|
|
104
|
+
|
|
105
|
+
* Snow Leopard (enable-shared AND disable-shared):
|
|
106
|
+
* x86_64 builds of Ruby Enterprise Edition 1.8.6/1.8.7
|
|
107
|
+
* x86_64 builds of MRI Ruby
|
|
108
|
+
|
|
109
|
+
Coming soon:
|
|
110
|
+
|
|
111
|
+
Official support for Ruby 1.9
|
|
112
|
+
Official support for i386/i686
|
|
113
|
+
|
|
114
|
+
== Special Thanks
|
|
115
|
+
* Jake Douglas for the Mach O/snow leopard support.
|
|
116
|
+
* Aman Gupta for various bug fixes and other cleanup.
|
|
117
|
+
* Rob Benson for 1.9 support and cleanup.
|
|
118
|
+
* Paul Barry for force_gc support in Memprof::Middleware
|
data/ext/memprof.c
CHANGED
|
@@ -1906,7 +1906,11 @@ init_memprof_config_extended() {
|
|
|
1906
1906
|
/* who knows what could happen */
|
|
1907
1907
|
if (TYPE(ruby_build_info) == T_STRING)
|
|
1908
1908
|
fprintf(stderr, "%s\n", StringValuePtr(ruby_build_info));
|
|
1909
|
-
|
|
1909
|
+
|
|
1910
|
+
fprintf(stderr, "\nTry installing debug symbols (apt-get install libruby1.8-dbg or similar), or using a "
|
|
1911
|
+
"Ruby built with RVM (http://rvm.beginrescueend.com/)\n\n");
|
|
1912
|
+
|
|
1913
|
+
errx(EX_SOFTWARE, "If that doesn't work, please email this output to bugs@memprof.com");
|
|
1910
1914
|
}
|
|
1911
1915
|
}
|
|
1912
1916
|
|
data/lib/memprof/middleware.rb
CHANGED
data/memprof.gemspec
CHANGED
metadata
CHANGED
|
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
|
5
5
|
segments:
|
|
6
6
|
- 0
|
|
7
7
|
- 3
|
|
8
|
-
-
|
|
9
|
-
version: 0.3.
|
|
8
|
+
- 5
|
|
9
|
+
version: 0.3.5
|
|
10
10
|
platform: ruby
|
|
11
11
|
authors:
|
|
12
12
|
- Joe Damato
|
|
@@ -17,7 +17,7 @@ autorequire:
|
|
|
17
17
|
bindir: bin
|
|
18
18
|
cert_chain: []
|
|
19
19
|
|
|
20
|
-
date: 2010-04-13 00:00:00 -
|
|
20
|
+
date: 2010-04-13 00:00:00 -04:00
|
|
21
21
|
default_executable:
|
|
22
22
|
dependencies:
|
|
23
23
|
- !ruby/object:Gem::Dependency
|
|
@@ -59,7 +59,7 @@ extra_rdoc_files: []
|
|
|
59
59
|
|
|
60
60
|
files:
|
|
61
61
|
- .gitignore
|
|
62
|
-
- README
|
|
62
|
+
- README.rdoc
|
|
63
63
|
- Rakefile
|
|
64
64
|
- bin/memprof
|
|
65
65
|
- ext/arch.h
|
data/README
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
memprof (c) Joe Damato @joedamato http://timetobleed.com
|
|
2
|
-
|
|
3
|
-
What is memprof?
|
|
4
|
-
================
|
|
5
|
-
Memprof is a memory profiler for Ruby that requires no patches to the Ruby VM.
|
|
6
|
-
It can help you find Ruby level memory leaks in your application.
|
|
7
|
-
|
|
8
|
-
How to use
|
|
9
|
-
==========
|
|
10
|
-
|
|
11
|
-
require 'memprof'
|
|
12
|
-
Memprof.start
|
|
13
|
-
|
|
14
|
-
# ruby code
|
|
15
|
-
|
|
16
|
-
Memprof.stats
|
|
17
|
-
|
|
18
|
-
# more ruby code
|
|
19
|
-
|
|
20
|
-
Memprof.stats
|
|
21
|
-
Memprof.stop
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
The above code will output 2 summaries, allowing you to compare which objects were
|
|
25
|
-
destroyed and which are still around.
|
|
26
|
-
|
|
27
|
-
Memprof.stats also takes an (optional) file name to write the output to a file.
|
|
28
|
-
|
|
29
|
-
Supported systems
|
|
30
|
-
=================
|
|
31
|
-
Currently supporting:
|
|
32
|
-
|
|
33
|
-
Linux (enable-shared AND disable-shared):
|
|
34
|
-
x86_64 builds of Ruby Enterprise Edition 1.8.6/1.8.7
|
|
35
|
-
x86_64 builds of MRI Ruby
|
|
36
|
-
|
|
37
|
-
Snow Leopard (enable-shared AND disable-shared):
|
|
38
|
-
x86_64 builds of Ruby Enterprise Edition 1.8.6/1.8.7
|
|
39
|
-
x86_64 builds of MRI Ruby
|
|
40
|
-
|
|
41
|
-
Support for unstripped binaries and stripped binaries if (and only if) the
|
|
42
|
-
symbol files live in /usr/lib/debug/
|
|
43
|
-
|
|
44
|
-
You can get symbol files for system Rubies by installing -dbg packages.
|
|
45
|
-
|
|
46
|
-
For example, on ubuntu: apt-get install libruby1.8-dbg
|
|
47
|
-
|
|
48
|
-
Snow Leopard:
|
|
49
|
-
x86_64 builds of Ruby Enterprise Edition 1.8.7
|
|
50
|
-
x86_64 builds of MRI Ruby (enable-shared and disable-shared)
|
|
51
|
-
Unstripped binaries only!
|
|
52
|
-
|
|
53
|
-
Experimental (somewhat broken) support:
|
|
54
|
-
|
|
55
|
-
Linux and OSX:
|
|
56
|
-
i386/i686 support.
|
|
57
|
-
|
|
58
|
-
Snow Leopard:
|
|
59
|
-
OSX system Ruby, distributed with Snow Leopard
|
|
60
|
-
|
|
61
|
-
Coming soon:
|
|
62
|
-
|
|
63
|
-
Official support for Ruby 1.9
|
|
64
|
-
Official support for i386/i686
|
|
65
|
-
|
|
66
|
-
CREDITS
|
|
67
|
-
=======
|
|
68
|
-
Jake Douglas for the Mach O/snow leopard support.
|
|
69
|
-
|
|
70
|
-
Aman Gupta for various bug fixes and other cleanup.
|
|
71
|
-
|
|
72
|
-
Rob Benson for 1.9 support and cleanup.
|