Wow, this is one of the most interesting discussions this list has had in a
long time.

One of my older, more experienced programming friends was talking about
precisely the problem of memory fragmentation during dynamic allocation.
However, he still insisted on using linked lists for his entities/particles.
Could the speed difference be on the level that either way could work
reasonably well on today's platform, while the system that was more mentally
accessible for him (and myself) won out? Sometimes the faster solution loses
out to the better one...

Just an observation. I would be talking about how memory bus speeds affect
the access of sequential and non-sequential information, but you know... I'm
just not sure. :P However, isn't RAM Random Access? How much difference is
there between accessing memory from a pointer and accessing memory from an
array?

----- Original Message -----
From: "botman" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, June 28, 2002 6:23 AM
Subject: Re: [hlcoders] Particle System


> > 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
>
>

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

Reply via email to