If I'm managing hundreds of thousands of objects in a 3D world (for a game) should I store them all in a vector? But what happens if I have 100 coin objects, and one get's garbage collected, how would I know which one already had a variable created for it? And isn't there a runtime object thing that runs the garbage collector to free up memory? Does that mean what I have to do the coin1 = null thing? Since I'll be managing hundreds of thousands of objects, this could become a problem.
coin coin1 = new coin();
coin coin2 = new coin();
coin coin3 = new coin();
coin coin4 = new coin();
coin4 = null;
coin4 = new coin();
How would I know which coin was which until the compiler spits out an error? Or am I doing this totally wrong? If a player drops an item, it gets set to null. But does that free up memory or totally destory the object? And if the game automatically generates objects, how would it name them, especially if some of the them skip, such as coin, coin2, coin4, if coin3 is gone
2007-03-24
18:04:26
·
3 answers
·
asked by
Invader Z
1