Amen Jim! Thanks for bringing some sense to this frenzy :)

new and delete (malloc and free) have to search for memory to allocate.

If you look at how some simple memory heaps are coded, its essentially a
large array (the heap) with utility functions that scan it linearly
looking for places to allocate/de-allocate.

In theory (and in my hopes) I would state that the OS's memory
management was optimized and thus significantly faster than code you
write.

However, there are still benefits to array-based implementations.....

For instance, if you implement your particle array as a queue, insertion
or deletion could be done in constant time. This would place a
restriction on the particle system - if particles A, B, C are created, C
must die out before B, which must die out before A....however, this is
usually the way particles are used, so its not much of a restriction.

Even an array of 2000 elements might suffice - all without the CPU
overhead of doing list operations.

david

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]] On Behalf Of Jim Hunter
Sent: Thursday, June 27, 2002 10:28 PM
To: [EMAIL PROTECTED]
Subject: Re: [hlcoders] Particle System

> Sure, having the ability to create a *variable* number of particles is
a
> plus by using a linked list over an array. Why have 20,000 dormant
> classes/structures taking up memory when you don't have to? How about
> allocating new particles? Are you supposed to scan through the entire
array
> each time you wish to create a new particle to find that indexes 919
and
> 9294-12300 are free? By using a linked list, you can simply store a
pointer
> to the last particle and then add on to it as necessary.

Forgive my ignorance, but aren't you just shifting that burden (of
finding
empty space to store a new particle) from your own code to the heap
manager?
I have no idea which would be more efficient, but either way,
*something*
has got to look for storage space and determine that it's unused, and
reclaim space that is no longer used.  I would bet the performance would
be
close to equal; anyone know if a formal analysis of such a problem has
been
done?  Just curious.

Jim

_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives,
please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders


_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders

Reply via email to