discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSArray: Problem allocating memory on stack on windows


From: Roland Schwingel
Subject: Re: NSArray: Problem allocating memory on stack on windows
Date: Thu, 9 Oct 2003 12:48:34 +0200




Hi

>
> Simply replacing stack based memory management with heap based stuff is
> not
> a good enough solution ... it's very slow.  Instead, what I do is a
> compromise ...
>
> I select what seems a reasonable size (say a few thousand elements) and
> code
> such that below this size we allocate memory on the stack, and above it
> we use
> the heap.   The rationale being that, where we are dealing with large
> enough
> amounts of data the overheads of heap management are proportionally
> smaller.
>
> For instance, if -initWithArray: used malloc/free for an array
> containing just a
> few objects, it would perhaps double the time taken by the array
> creation/initialisation,
> but if it did it for an array containing 10000 objects, it would
> probably only
> make a 1% difference.
>
> Unfortunately, having two ways of dealing with the memory means more
> code,
> and more chance of bugs ... so generally when adopting this scheme I
> initially
> set the changeover point very small, so it's easy to exercise both
> schemes,
> and only increase it when I'm confident both are working well.
>
Having it duplicate for speed reason might be a good idea, as already
written as response to Nicolas mail. And your are also right more code
means more chances to fail. For the malloc/free solution I can tell we
use it here for ~1 week in everyday use in NSArray and had yet nomore
problems (and no new problems).

Roland





reply via email to

[Prev in Thread] Current Thread [Next in Thread]