I have the following function that is continuously called from run () of a thread that runs continuously.
private LinkedList<short[]> playerData = new LinkedList<short[]>(); public synchronized void setPlayerData(short[] buffer) {
Now the Tracker DDMS distribution says that many objects were created inside addLast () (actually inside addLastImpl ()), so for this I would like to explicitly delete arrays so that they always have enough memory on the heap. Now
- System.gc () will not help, because it will be called at the same time each time setPlayerData () is called.
- GC_CONCURRENT eats all processor cycles, because the application is very time sensitive, and even a small delay in the second second is unacceptable.
For information about LogCat, see the section, which is my other question regarding the entire synarion. In this thread, I'm just trying to solve this big problem by dividing it into many small problems.
Possible solution . A possible solution would be to free up memory space exploit by removing arrays that are not required. But in Java, how can we free the array created by the new operator? those.
short[] buffer = new short[320]; // do some operation on buffer /// now how can I explicitly free memory by deleting the buffer, when its job is over..
I know there is garbage collection to take care of all such things. But in my application, GC_CONCURRENT eats all the time. Because of this, because of this, other processes disappear. It would be great if I could explicitly free the memory, i.e. Delete in C ++. Here you can see the LogCat information ... A detailed question about my problem
EDIT 2 3. Assign arrays to zero
How does this help? null arrays will be assigned to the garbage collection, which I want to avoid, since the method is called from the stream continuously (every 20 ms). If I set the array to zero, GC_FOR_MALLOC messages will populate LogCat ...