Re: correctly Controlling Garbage Collection
Re: correctly Controlling Garbage Collection
- Subject: Re: correctly Controlling Garbage Collection
- From: Rob Keniger <email@hidden>
- Date: Sun, 18 Oct 2009 11:48:19 +1000
On 16/10/2009, at 4:17 PM, WareTo Development wrote:
> Looking at this problem, we could perform better memory management, so deep garbage collection does not happen that often. This reduces the problem, but can never eliminate it, since sooner or later the garbage clean operation must be done.
>
> So we thought the best thing would be to force a garbage collection operation at a time of our choosing. Normally, this occurs at Mouse up, after the user has finished his drawing. A split second of garbage collection then would be barely noticeable by the user.
What happens if you explicitly disable Garbage Collection when the user starts drawing and enable it when the user finishes?
Something like:
- (void)mouseDown:(NSEvent*)event
{
[[NSGarbageCollector defaultCollector] disable];
//other mouse down stuff
}
- (void)mouseUp:(NSEvent*)event
{
[[NSGarbageCollector defaultCollector] enable];
[[NSGarbageCollector defaultCollector] collectExhaustively];
//other mouse up stuff
}
That way the collector should never fire while the user is drawing.
--
Rob Keniger
_______________________________________________
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