> In my OpenGL system I just have one linked list for all of my particle
> entities. To render I simply go through the entire list. To add a particle
> I simply dynamically allocate one add it to the end. For removing a
> particle, I deallocate it and update the links of the one before and after
> it. Very simple and it works extremely well. Don't see how an array could
> be better unless you are very sloppy with memory.

One problem with linked lists is that they aren't contiguous in memory
(usually).  When the heap gets fragmented, memory that you allocate will be
all over the place.  As you walk through this linked list, the processor
will have to page fault on every page access, which causes the CPU to have
to do a RAM access to transfer a block of memory to the processor cache.

Arrays are always contiguous in memory and you will only page fault when
crossing a memory page boundry.  So looping through 10,000 particles could
take hundreds of times longer on a linked list than on an array (depending
on the speed of your memory bus).

Jeffrey "botman" Broome

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

Reply via email to