Too many junk junk issues

I have an application basically creating a new byte array (less than 1 KB) that stores some data after a few seconds (usually less than 1 minute, but some data is stored up to 1 hour) are written to disk and the data will be garbage. About 400 packets per second are generated. I read some articles that say don't worry about the GC, especially the quickly created and released pieces of memory (in Java 6). GC has been running for too long, which causes some problems in my application. I set some GC parameters (Bigger XMX and ParalelGC), this reduces the total reduction in GC time, but not enough yet. I have an idea 2, Can I focus GC parameters or create a byte array memory pool mechanism? Which one is better?

+3
source share
3 answers

I suggest you analyze why the GC doesn't work well enough for you. You can use jmapto unload the heap, and then use jhateither Eclipse Memory Analyzer to find out what objects live in it. You may find yourself sticking to links that you no longer need.

GC is very smart, and you can really do something worse by trying to outwit it with your own memory management code. Try tweaking the settings, and maybe you can also try the new G1 garbage collector.

Also, remember that the GC loves short-lived, immutable objects.

0
source

GC , ( ) . , , , , . .

ByteBuffer . [], , NIO. . ( )

BTW: , "C".

+4
  • WeakReferences.
  • GC algo VM.
-Xgc: parallel
  • mem
-XX:+UseISM -XX:+AggressiveHeap
  • .

-XX:SurvivorRatio 8

0
source

Source: https://habr.com/ru/post/1785903/


All Articles