mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
Help avoid programs getting huge memory footprints when they don't need to.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@23077 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
7503f52474
commit
db7cf4a3fc
3 changed files with 32 additions and 44 deletions
|
@ -1,6 +1,9 @@
|
|||
2006-06-17 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/GSString.m: Fix memory leak.
|
||||
* Source/NSAutoreleasePool.m: Optimise -emptyPool method.
|
||||
* Source/NSRunLoop.m: Empty autorelease pool after firing each
|
||||
timer/event so that huge memory footprints are less likely to occur.
|
||||
|
||||
2006-06-16 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
|
|
|
@ -319,6 +319,30 @@ static IMP initImp;
|
|||
- (void) dealloc
|
||||
{
|
||||
struct autorelease_thread_vars *tv = ARP_THREAD_VARS;
|
||||
|
||||
[self emptyPool];
|
||||
|
||||
/*
|
||||
* Remove self from the linked list of pools in use.
|
||||
* We already know that we have deallocated our child (if any),
|
||||
* but we may have a parent which needs to know we have gone.
|
||||
*/
|
||||
if (tv->current_pool == self)
|
||||
{
|
||||
tv->current_pool = _parent;
|
||||
}
|
||||
if (_parent != nil)
|
||||
{
|
||||
_parent->_child = nil;
|
||||
}
|
||||
|
||||
/* Don't deallocate ourself, just save us for later use. */
|
||||
push_pool_to_cache (tv, self);
|
||||
GSNOSUPERDEALLOC;
|
||||
}
|
||||
|
||||
- (void) emptyPool
|
||||
{
|
||||
unsigned i;
|
||||
Class classes[16];
|
||||
IMP imps[16];
|
||||
|
@ -384,50 +408,6 @@ static IMP initImp;
|
|||
released = released->next;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove self from the linked list of pools in use.
|
||||
* We already know that we have deallocated our child (if any),
|
||||
* but we may have a parent which needs to know we have gone.
|
||||
*/
|
||||
if (tv->current_pool == self)
|
||||
{
|
||||
tv->current_pool = _parent;
|
||||
}
|
||||
if (_parent != nil)
|
||||
{
|
||||
_parent->_child = nil;
|
||||
}
|
||||
|
||||
/* Don't deallocate ourself, just save us for later use. */
|
||||
push_pool_to_cache (tv, self);
|
||||
GSNOSUPERDEALLOC;
|
||||
}
|
||||
|
||||
- (void) emptyPool
|
||||
{
|
||||
struct autorelease_array_list *released;
|
||||
|
||||
if (_child)
|
||||
{
|
||||
[_child dealloc];
|
||||
}
|
||||
|
||||
released = _released_head;
|
||||
while (released)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < released->count; i++)
|
||||
{
|
||||
id anObject = released->objects[i];
|
||||
released->objects[i] = nil;
|
||||
[anObject release];
|
||||
}
|
||||
released->count = 0;
|
||||
released = released->next;
|
||||
}
|
||||
_released = _released_head;
|
||||
}
|
||||
|
||||
- (void) _reallyDealloc
|
||||
|
|
|
@ -405,6 +405,7 @@ static NSComparisonResult tSort(GSIArrayItem i0, GSIArrayItem i1)
|
|||
|
||||
- (void) _checkPerformers: (GSRunLoopCtxt*)context
|
||||
{
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
if (context != nil)
|
||||
{
|
||||
GSIArray performers = context->performers;
|
||||
|
@ -462,9 +463,11 @@ static NSComparisonResult tSort(GSIArrayItem i0, GSIArrayItem i1)
|
|||
{
|
||||
[array[i] fire];
|
||||
RELEASE(array[i]);
|
||||
IF_NO_GC([arp emptyPool]);
|
||||
}
|
||||
}
|
||||
}
|
||||
RELEASE(arp);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -793,6 +796,7 @@ extern IMP wRetImp;
|
|||
&& ([timerDate(t) timeIntervalSinceReferenceDate] <= now))
|
||||
{
|
||||
[t fire];
|
||||
IF_NO_GC([arp emptyPool]);
|
||||
now = GSTimeNow();
|
||||
}
|
||||
|
||||
|
@ -831,6 +835,7 @@ extern IMP wRetImp;
|
|||
RELEASE(min_timer);
|
||||
}
|
||||
GSNotifyASAP(); /* Post notifications. */
|
||||
IF_NO_GC([arp emptyPool]);
|
||||
}
|
||||
_currentMode = savedMode;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue