unknown wrote: > On Wed, 16 Apr 2008, Emanuele Ricci wrote: > >> I just discovered that ruby allocates memory in 8Mb chunks. >> Forgive my ignorance. >> Is there a way to change this behaviour? Since my app runs in an >> environment with very strict memory constraints, a memory spike of 8Mb >> can be lethal... >> I would change it to a lower figure. > > In the Ruby source, in gc.c: > > #ifndef GC_MALLOC_LIMIT > #if defined(MSDOS) || defined(__human68k__) > #define GC_MALLOC_LIMIT 200000 > #else > #define GC_MALLOC_LIMIT 8000000 > #endif > #endif > > > Start there. > > > Kirk Haines Thank you all for the very useful hints. I solved a problem I had for a very long time. I thought it was a memory leak but I couldn't find any. Now I know that it was simply ruby allocating memory. Due to the heavy memory constraints I have in my enviroement (an arm-linux embedded device) an allocation of 8Mb of memory could cause a crash of my app due to not enough memomry. To solve the problem I simply changed #define GC_MALLOC_LIMIT 8000000 to #define GC_MALLOC_LIMIT 1000000 in gc.c. That is enough to solve my problem and to not cause the garbage collector to be called too often. Thank you again, Emanuele Ricci. -- Posted via http://www.ruby-forum.com/.