Jump to content
  • Advertisement
Sign in to follow this  
nullsquared

Particles memory usage - increasing but not decreasing [C++].

This topic is 4710 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok, so I have a particle system. It has addParticles and addParticle. Each one pushes back a new Particle* into a std::list. I have a vector of list iterators. When I iterate over the particles and update them, I check if they are dead. If they are, the iterator with the poor poor particle is pushed back into the vector. At the end, everything in the vector is delete'ed and removed from the list. HOWEVER, memory usage in Task Manager continues to increase... Even by JUST adding 2 particles in 1 frame. I'm guessing this is because twice as many particles are deleted than newed, but this shouldn't be this way... should it? Maybe, (what I thought) was that I was giving each particle between 100 and 150 chances to move... Maybe I'm not realizing they are deleted or something? Even when letting them move only 5 times the memory keeps increasing and never decreasing.... I'm getting confused. Any ideas? EDIT: The interesting part is that there is NO slowdown...

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by agi_shi
Ok, so I have a particle system. It has addParticles and addParticle. Each one pushes back a new Particle* into a std::list. I have a vector of list iterators. When I iterate over the particles and update them, I check if they are dead. If they are, the iterator with the poor poor particle is pushed back into the vector. At the end, everything in the vector is delete'ed and removed from the list.

HOWEVER, memory usage in Task Manager continues to increase... Even by JUST adding 2 particles in 1 frame. I'm guessing this is because twice as many particles are deleted than newed, but this shouldn't be this way... should it?

Maybe, (what I thought) was that I was giving each particle between 100 and 150 chances to move... Maybe I'm not realizing they are deleted or something?

Even when letting them move only 5 times the memory keeps increasing and never decreasing.... I'm getting confused.

Any ideas?

EDIT:
The interesting part is that there is NO slowdown...



DUH! I wasn't deleting the SDL surfaces. Sorry guys.

Share this post


Link to post
Share on other sites
Glad you got it sorted but I have to ask; why are you using a vector to store the dead particles? Would it not be quicker and easier to just delete the items from the list as they're dead? The good thing about a list is that iterators are not invalidated when items are added to or deleted from a list.

Share this post


Link to post
Share on other sites
agi_shi, glad you got your problem sorted out. You should note however that the Task Manager is not an accurate gauge of memory usage.

Mark

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!