Hi.
Here's my problem:
I have a big, empty flat world I can walk around in. So far, everything works fine.
Now I want to put some trees in that world. I have three different "types" of trees. Oak, Fir, and Beech. The placing of all the trees in that world is determined by a fractal algorithm. Therefore, I never know how many trees (or how much of one type) are standing in my current environment, while I'm walking through that world. My visible range in every direction is ~ 1 mile.
Because of the Garbage collector, it seems not efficient to create the trees during runtime.
So, I thought about loading my meshes for Oak, Fir, and Beech on startup into three static 3D-Objects, which are cloned dynamically on runtime as the need arises. Because the clones are references, the memory usage would stay small, right?
The problem is, if I walk from a forest of Oaks into a forest of Firs, what shall I do with all the Oaks? How can I delete the clone objects in order to free some memory? Or is there a way to reassign the mesh-reference of a clone object? And how can I add a new clone object on the fly into the world anyway?
Or would it be better to create three big arrays of trees at startup? For Example:
Oaks[100]; Firs[100]; Beeches[100];
Placing all of them "down under" at startup, and making them visible via xyz-transformation during runtime????
Well ... I think there's a more elegant solution for my problem than that, isn't there?
For desktop Java, i wouldn't worry too much about the garbage collector. It's usually not a problem. On Android, it's another story...
I got the solution:
it was: world.removeObject(...);
Thanks anyway.