On Jan 17, 2008 3:36 PM, yitzle <[EMAIL PROTECTED]> wrote: > DumpSizes tells me I'm only using around 200KB RAM. > Yet top reports close to 10MB, mostly in the DATA segment. > Where is that memory going? Is it probably the includes? I don't see > where else it can be.
As it runs, your perl binary allocates and deallocates memory. In general, when it needs more, it asks the OS for more; when it no longer needs some, it doesn't give it back. As a result, you may have more memory allocated than your program needs now, because it needed it a moment ago. And, of course, it may need it again in another moment; that's part of why it doesn't give the memory back. This may sound inefficient of memory, but it's probably not. That's partially because most modern operating systems use virtual memory, instead of real memory; so, mostly, you only need as much real memory as your programs are actually using at any given moment. If you have many similar programs running, especially if they each run for many minutes at a time, there probably is some way that they can be reorganized to use less memory as a group. Let us know if that's the case. If your system is so low on memory that a single program requiring 10MB causes shortages, you should probably get more memory. (Ah, for the days when 16k was a memory upgrade!) If your system isn't running low on memory, you probably shouldn't worry about it. If, despite everyone's advice, you spend the next couple of months tuning your program to use less RAM, you'll probably find that you've made it much slower and less efficient as well. (It was using some of that memory to hold values that it would otherwise need to recalculate, you see.) It would be more efficient in the long run to spend your time working at the car wash and earning enough in tips to buy that extra memory, which you can then use to play NetHack with the rest of us. Now you see why Perl programmers don't spend much time worrying about memory management. Cheers! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/