I am developing a function (Java method) that will execute 40-80 times per second on a mobile device.
I want to avoid creating tons of dead variables that the GC collects as the function launches (possibly throughout the life of the application).
In C, I can use volatile , for example, to prevent the allocation of memory by my variables each time the function is executed ... I want to do something similar in Java, but I donβt know how to do it.
The function stores data in
- 1 row
- 4 integers
- 2 1-dimensional array of strings
In general, in Java, what is the preferred method to use the above variables, but not redistribute them every time my function is executed (40+ times per second)?
Member elements will work, but is this the best solution?
Thanks! Brad
java optimization memory-management
Brad hein
source share