Idea about memory management. Game related.
Chad J
gamerChad at _spamIsBad_gmail.com
Mon Jun 12 11:52:22 PDT 2006
MM wrote:
> Okay, so reading and writing to those arrays would not trigger gc, right?
> I can use arrays without malloc as long as I don't change it size, right?
> right? :D
>
>
Afaik, those things should be fine.
Only one other thing I can think of to watch out for at the moment:
byte[] A = new byte[128];
byte[] B = new byte[64];
A = B;
Once it executes A = B, the memory held by what was once A is leaked
until a garbage collection occurs. I'm not sure, but this could mean
longer and more frequent garbage collections, unless you avoid
allocating on the gc heap altogether for the rest of the program's
execution. This would call for some manual management, like so:
byte[] A = new byte[128];
byte[] B = new byte[64];
delete A;
A = B;
Just make sure there don't happen to be other references to A floating
around in your program, or you are setting yourself up for disaster.
Also realize that you might be able to get away with using some GC.
What I worry about is that I don't know how well this will work in a
large game. But as long as the garbage collections don't last long
enough to be noticable, you are fine.
More information about the Digitalmars-d
mailing list