Robert Klemme wrote in post #1113449:
> How exactly do you imagine "memory usage by methods" to be measured?
> Are you just interested in learning how much memory is allocated (temporarily) 
from withing a method or do you have a memory leak?

I'm interested in figuring out the memory peaks of specific code pieces. 
Even if memory gets freed up at some point, I'd still like to know the 
amount that was used just right before to be able to calculate the 
amount that would be used by concurrent processes.

And also to see the history of memory usage by methods compared to each 
other so that I know which part of the code I should rewrite to make it 
more memory efficient.

> I usually found "ruby -r profile" helpful.  You can also use module
> Benchmark for measuring timing of specific parts of code.  You can even
> use
> Benchmark.measure { ... } around a specific piece and you'll get CPU,
> system and wall clock time in an instance of class Benchmark::Tms,

I use these tools and they work great. Only they've got nothing to do 
with memory consumption.

> For memory leak detection I once created a small tool with ObjectSpace
> which just counts instances per class and outputs deltas.  You might
> find
> it in the archives of this forum.

If I understand you correctly, you say I can only see the counted sum of 
these objects? But I reckon I still won't be able to calculate memory 
usage by this.

ruby-prof would have similar with its RubyProf::ALLOCATIONS I believe, 
unfortunately I can't get it to work. But anyway, your solution can be 
more than nothing. I'll check it out later on. Though I'm still keen to 
find a solution for what I described above.

Thanks.

-- 
Posted via http://www.ruby-forum.com/.