Paul wrote:
> one of my ruby apps has a memory leak. Ive looked through the code and
> cant find it.
> 
> I have about 6000 lines (so please dont ask me to post the code) using
> FX ruby and 10 or so classes I have written.
> 
> Im able to switch the gui off and run, but the memory leak still
> happens, so its not FX or my gui code.
> 
> The app starts at around 15M, and increases to about 100M after 3
> days.
> 
> This is using ruby 1.8.1  (2004-01-27) [i386-mswin32] from the Windows
> installer. It happens on both XP and W2k
> 
> I think I may be able to run the suspect code outside of the main app,
> so Im going to try that now.
> 
> Can any one give me any ideas on how to find the leak?

Keep chopping down the code, and try to find a minimal reproducible 
case? That may be hard if it takes days to tell if the leak is happening.

Do you know whether this is a true memory leak (allocated memory that is 
unreachable) or just objects that are piling up somewhere (reachable but 
unused). You might be able to detect this using ObjectSpace.each_object. 
It would at least tell you if the number of objects is growing, but it 
wouldn't tell you if resizable objects (arrays, strings, etc.) were growing.

What I've wished for before was ObjectSpace.memory_allocated, which 
would tell you how much memory the ruby memory manager knows about and 
would answer this question directly.