Clear big AAs

bearophile bearophileHUGS at lycos.com
Mon Jun 13 14:41:11 PDT 2011


useo:

> toRender is my AA which contains the textures as key (instances of my
> class "Texture") and the tiles (position of them) as values. When I
> remove the first two lines (clear and set null) it doesn't drops down
> to 1 FPS, it runs normal.
> 
> I hope anyone know a solution :)

Try to disable the GC before that double loop and enable after it. Generally those appends create lot of garbage, so it's not something to do in a performance critical part of the program (try to use fixed-sized arrays, or structs with a fixed-sized array plus a length). You can also try an AA of appender. Also try to profile your code, and take a look at GC stats.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list