vm keeps increasing when in a rigorous loop
vm keeps increasing when in a rigorous loop
- Subject: vm keeps increasing when in a rigorous loop
- From: Nick Rogers <email@hidden>
- Date: Sun, 08 Jul 2012 23:36:12 +0530
Hi,
The code is like:
- (void)myMethod
{
.........
while (flag) {
UInt32 temp;
..... and lot of other ints etc.
if (someCondition == 1) {
UInt8 *buff = (UInt8*)calloc(1, sizeof(aStruct));
if (someOtherCondition == 1) {
[self addPointerToATree:buff];
}
else
free(buff);
}
}
}
The while loop runs very rigorously without having much delay in it.
Memory for buff is only needed when certain condition is met.
I have seen that even when this condition is not met and no memory is allocated, the VM keeps growing steadily as seen in Activity Monitor.
So the only thing contributing to it would be the various ints etc.
But the app is GC enabled (required), so the VM size should reset to some level every few seconds, but doesn't.
The loop does many thousands of iterations per second.
Any idea on how to limit this usage?
Shall help.
I have a auto release pool drained at the end of every iteration in a loop in some other method but that doesn't seem to have much effect.
Wishes,
Nick
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden