Re: Memory Auto-Increasing
Re: Memory Auto-Increasing
- Subject: Re: Memory Auto-Increasing
- From: Sherm Pendley <email@hidden>
- Date: Sat, 1 Jun 2002 16:28:52 -0400
On Saturday, June 1, 2002, at 12:56 PM, Lorenzo Puleo wrote:
My application, while a recursive routine is running, increases its
"Resident Memory Size" and its "Virtual Memory Size". I saw this using
ProcessViewer utitlity. Sincerely I don't know what is causing that.
I don't see any obvious leaks in your code, but recursion can be very
memory intensive even without leaks.
Local variables are allocated on a stack. The classic example of a stack
is a stack of dishes. When a plate is added, it sits on the top of the
stack. When a plate is removed, it is taken from the top of the stack.
Each time a method is called, a new set of plates (local variables) is
created and added to the top of the stack. When the method returns, the
plates that belong to it (its local variables) are taken off the top of
the stack.
When recursion is used, local variables for each recursive method call
are allocated and placed on top of the stack, over top of any existing
variables belonging to previous calls to that method. So, the stack
grows until the maximum depth of nested method calls is reached. At that
point, as nested method calls begin returning back up towards the first,
the stack shrinks as each return removes its local variables from the
stack.
Hope this helps!
sherm--
Never put off until tomorrow what you can do today. There might be a law
against it by that time.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.