I am trying to improve performance in a game I have written.
I was wondering if Java has a built in feature that could be easily
enabled to count unique class instantiations.
I am concerned in my functions which execute 100 times a second (well at
least they are supposed to) that I am needlessly recreating objects over
and over and over again. Perhaps for simple data this is not a large
consideration (a single string 1 time) - but for instance, I was doing
something like creating a unique "Rect" (Rectangle class) for every
sprite in the entire board, every frame iteration to check for
collisions. Since there are between hundreds and thousands of blocks
which make a board - I was needlessly creating millions of objects per
second - which then had to be garbage collected.
I am not asking for game engine specific optimization techniques - that
would no doubt be a question best suited for the GTGE forums.
I just want to see a count of instances classes which were instantiated
or garbage collected - and if anything ever hits 100 million then
perhaps I can raise a flag to check for it.
Even better would be instantiation count from unique position in the
call stack - so it wouldn't be such a needle in a haystack.
Does such a mechanism exist?
Thank you
--
Luc The Perverse