Hallo zusammen,
ich habe aktuell ein Problem, wo mein Code beim ausführen den Speicher nach einer Ausführung nicht wieder frei gibt.
Der Code ist etwas größer aber im Prinzip wird nach dem Auslösen eines Events ein neuer Thread gestartet der Inhalte des Events verarbeitet und sich danach beendet. Jetzt würde ich erwarten das der Speicher beim beenden des Threads wieder frei gegeben wird, allerdings scheint das nicht so wirklich der Fall zu sein, weshalb sich das ganze relativ zügig daran macht alles einzunehmen was verfügbar ist.
Direkt nach dem starten scheinen knapp 113MB Speicher reserviert zu sein (htop).
Nach etwa 50 ausgelösten Events sind es scheinbar bereits knapp 400MB.
Eigentlich würde ich einen Wert um 113MB erwarten, da alle gestarteten Threads wieder beendet wurden. Führe ich nun manuell eine GC aus (evtl wurde ja noch keine ausgeführt), wird zwar einiges entfernt (262 statt 400MB) allerdings eben nicht annähernd alles.
Das ganze läuft auf OpenJDK 11.0.3 ohne das ich beim starten weitere Flags setze.
Wie müsste ich das ganze konfigurieren damit es eben alles regelmäßig wieder aufräumt?
Viele Grüße
ich habe aktuell ein Problem, wo mein Code beim ausführen den Speicher nach einer Ausführung nicht wieder frei gibt.
Der Code ist etwas größer aber im Prinzip wird nach dem Auslösen eines Events ein neuer Thread gestartet der Inhalte des Events verarbeitet und sich danach beendet. Jetzt würde ich erwarten das der Speicher beim beenden des Threads wieder frei gegeben wird, allerdings scheint das nicht so wirklich der Fall zu sein, weshalb sich das ganze relativ zügig daran macht alles einzunehmen was verfügbar ist.
Direkt nach dem starten scheinen knapp 113MB Speicher reserviert zu sein (htop).
garbage-first heap total 485376K, used 16881K [0x0000000628c00000, 0x0000000800000000)
region size 1024K, 16 young (16384K), 3 survivors (3072K)
Metaspace used 11732K, capacity 12067K, committed 12288K, reserved 1060864K
class space used 1313K, capacity 1443K, committed 1536K, reserved 1048576K
region size 1024K, 16 young (16384K), 3 survivors (3072K)
Metaspace used 11732K, capacity 12067K, committed 12288K, reserved 1060864K
class space used 1313K, capacity 1443K, committed 1536K, reserved 1048576K
Total Usage ( 140 loaders):
Non-Class: 343 chunks, 10.44 MB capacity, 10.21 MB ( 98%) used, 215.75 KB ( 2%) free, 296 bytes ( <1%) waste, 21.44 KB ( <1%) overhead, deallocated: 195 blocks with 71.71 KB
Class: 179 chunks, 1.41 MB capacity, 1.28 MB ( 91%) used, 118.98 KB ( 8%) free, 16 bytes ( <1%) waste, 11.19 KB ( <1%) overhead, deallocated: 37 blocks with 13.94 KB
Both: 522 chunks, 11.85 MB capacity, 11.49 MB ( 97%) used, 334.73 KB ( 3%) free, 312 bytes ( <1%) waste, 32.62 KB ( <1%) overhead, deallocated: 232 blocks with 85.65 KB
Virtual space:
Non-class space: 12.00 MB reserved, 10.50 MB ( 88%) committed
Class space: 1.00 GB reserved, 1.50 MB ( <1%) committed
Both: 1.01 GB reserved, 12.00 MB ( 1%) committed
Chunk freelists:
Non-Class:
specialized chunks: 2, capacity 2.00 KB
small chunks: 7, capacity 28.00 KB
medium chunks: (none)
humongous chunks: (none)
Total: 9, capacity=30.00 KB
Class:
specialized chunks: (none)
small chunks: (none)
medium chunks: (none)
humongous chunks: (none)
Total: 0, capacity=0 bytes
Waste (percentages refer to total committed size 12.00 MB):
Committed unused: 124.00 KB ( 1%)
Waste in chunks in use: 312 bytes ( <1%)
Free in chunks in use: 334.73 KB ( 3%)
Overhead in chunks in use: 32.62 KB ( <1%)
In free chunks: 30.00 KB ( <1%)
Deallocated from chunks in use: 85.65 KB ( <1%) (232 blocks)
-total-: 607.31 KB ( 5%)
MaxMetaspaceSize: 17179869184.00 GB
InitialBootClassLoaderMetaspaceSize: 4.00 MB
UseCompressedClassPointers: true
CompressedClassSpaceSize: 1.00 GB
Non-Class: 343 chunks, 10.44 MB capacity, 10.21 MB ( 98%) used, 215.75 KB ( 2%) free, 296 bytes ( <1%) waste, 21.44 KB ( <1%) overhead, deallocated: 195 blocks with 71.71 KB
Class: 179 chunks, 1.41 MB capacity, 1.28 MB ( 91%) used, 118.98 KB ( 8%) free, 16 bytes ( <1%) waste, 11.19 KB ( <1%) overhead, deallocated: 37 blocks with 13.94 KB
Both: 522 chunks, 11.85 MB capacity, 11.49 MB ( 97%) used, 334.73 KB ( 3%) free, 312 bytes ( <1%) waste, 32.62 KB ( <1%) overhead, deallocated: 232 blocks with 85.65 KB
Virtual space:
Non-class space: 12.00 MB reserved, 10.50 MB ( 88%) committed
Class space: 1.00 GB reserved, 1.50 MB ( <1%) committed
Both: 1.01 GB reserved, 12.00 MB ( 1%) committed
Chunk freelists:
Non-Class:
specialized chunks: 2, capacity 2.00 KB
small chunks: 7, capacity 28.00 KB
medium chunks: (none)
humongous chunks: (none)
Total: 9, capacity=30.00 KB
Class:
specialized chunks: (none)
small chunks: (none)
medium chunks: (none)
humongous chunks: (none)
Total: 0, capacity=0 bytes
Waste (percentages refer to total committed size 12.00 MB):
Committed unused: 124.00 KB ( 1%)
Waste in chunks in use: 312 bytes ( <1%)
Free in chunks in use: 334.73 KB ( 3%)
Overhead in chunks in use: 32.62 KB ( <1%)
In free chunks: 30.00 KB ( <1%)
Deallocated from chunks in use: 85.65 KB ( <1%) (232 blocks)
-total-: 607.31 KB ( 5%)
MaxMetaspaceSize: 17179869184.00 GB
InitialBootClassLoaderMetaspaceSize: 4.00 MB
UseCompressedClassPointers: true
CompressedClassSpaceSize: 1.00 GB
garbage-first heap total 485376K, used 104069K [0x0000000628c00000, 0x0000000800000000)
region size 1024K, 91 young (93184K), 14 survivors (14336K)
Metaspace used 118618K, capacity 121648K, committed 122624K, reserved 1159168K
class space used 12112K, capacity 13849K, committed 13952K, reserved 1048576K
region size 1024K, 91 young (93184K), 14 survivors (14336K)
Metaspace used 118618K, capacity 121648K, committed 122624K, reserved 1159168K
class space used 12112K, capacity 13849K, committed 13952K, reserved 1048576K
Total Usage ( 867 loaders):
Non-Class: 3378 chunks, 105.27 MB capacity, 104.01 MB ( 99%) used, 1.05 MB ( 1%) free, 3.76 KB ( <1%) waste, 211.12 KB ( <1%) overhead, deallocated: 3490 blocks with 1.96 MB
Class: 1410 chunks, 13.52 MB capacity, 11.83 MB ( 87%) used, 1.61 MB ( 12%) free, 16 bytes ( <1%) waste, 88.12 KB ( <1%) overhead, deallocated: 541 blocks with 377.14 KB
Both: 4788 chunks, 118.80 MB capacity, 115.84 MB ( 98%) used, 2.66 MB ( 2%) free, 3.77 KB ( <1%) waste, 299.25 KB ( <1%) overhead, deallocated: 4031 blocks with 2.32 MB
Virtual space:
Non-class space: 108.00 MB reserved, 106.12 MB ( 98%) committed
Class space: 1.00 GB reserved, 13.62 MB ( 1%) committed
Both: 1.11 GB reserved, 119.75 MB ( 11%) committed
Chunk freelists:
Non-Class:
specialized chunks: 1, capacity 1.00 KB
small chunks: 192, capacity 768.00 KB
medium chunks: (none)
humongous chunks: (none)
Total: 193, capacity=769.00 KB
Class:
specialized chunks: 1, capacity 1.00 KB
small chunks: 3, capacity 6.00 KB
medium chunks: (none)
humongous chunks: (none)
Total: 4, capacity=7.00 KB
Waste (percentages refer to total committed size 119.75 MB):
Committed unused: 200.00 KB ( <1%)
Waste in chunks in use: 3.77 KB ( <1%)
Free in chunks in use: 2.66 MB ( 2%)
Overhead in chunks in use: 299.25 KB ( <1%)
In free chunks: 776.00 KB ( <1%)
Deallocated from chunks in use: 2.32 MB ( 2%) (4031 blocks)
-total-: 6.24 MB ( 5%)
MaxMetaspaceSize: 17179869184.00 GB
InitialBootClassLoaderMetaspaceSize: 4.00 MB
UseCompressedClassPointers: true
CompressedClassSpaceSize: 1.00 GB
Non-Class: 3378 chunks, 105.27 MB capacity, 104.01 MB ( 99%) used, 1.05 MB ( 1%) free, 3.76 KB ( <1%) waste, 211.12 KB ( <1%) overhead, deallocated: 3490 blocks with 1.96 MB
Class: 1410 chunks, 13.52 MB capacity, 11.83 MB ( 87%) used, 1.61 MB ( 12%) free, 16 bytes ( <1%) waste, 88.12 KB ( <1%) overhead, deallocated: 541 blocks with 377.14 KB
Both: 4788 chunks, 118.80 MB capacity, 115.84 MB ( 98%) used, 2.66 MB ( 2%) free, 3.77 KB ( <1%) waste, 299.25 KB ( <1%) overhead, deallocated: 4031 blocks with 2.32 MB
Virtual space:
Non-class space: 108.00 MB reserved, 106.12 MB ( 98%) committed
Class space: 1.00 GB reserved, 13.62 MB ( 1%) committed
Both: 1.11 GB reserved, 119.75 MB ( 11%) committed
Chunk freelists:
Non-Class:
specialized chunks: 1, capacity 1.00 KB
small chunks: 192, capacity 768.00 KB
medium chunks: (none)
humongous chunks: (none)
Total: 193, capacity=769.00 KB
Class:
specialized chunks: 1, capacity 1.00 KB
small chunks: 3, capacity 6.00 KB
medium chunks: (none)
humongous chunks: (none)
Total: 4, capacity=7.00 KB
Waste (percentages refer to total committed size 119.75 MB):
Committed unused: 200.00 KB ( <1%)
Waste in chunks in use: 3.77 KB ( <1%)
Free in chunks in use: 2.66 MB ( 2%)
Overhead in chunks in use: 299.25 KB ( <1%)
In free chunks: 776.00 KB ( <1%)
Deallocated from chunks in use: 2.32 MB ( 2%) (4031 blocks)
-total-: 6.24 MB ( 5%)
MaxMetaspaceSize: 17179869184.00 GB
InitialBootClassLoaderMetaspaceSize: 4.00 MB
UseCompressedClassPointers: true
CompressedClassSpaceSize: 1.00 GB
garbage-first heap total 116736K, used 31904K [0x0000000628c00000, 0x0000000800000000)
region size 1024K, 2 young (2048K), 0 survivors (0K)
Metaspace used 118620K, capacity 121648K, committed 122624K, reserved 1159168K
class space used 12112K, capacity 13849K, committed 13952K, reserved 1048576K
region size 1024K, 2 young (2048K), 0 survivors (0K)
Metaspace used 118620K, capacity 121648K, committed 122624K, reserved 1159168K
class space used 12112K, capacity 13849K, committed 13952K, reserved 1048576K
Total Usage ( 867 loaders):
Non-Class: 3378 chunks, 105.27 MB capacity, 104.01 MB ( 99%) used, 1.05 MB ( <1%) free, 3.76 KB ( <1%) waste, 211.12 KB ( <1%) overhead, deallocated: 3818 blocks with 2.04 MB
Class: 1410 chunks, 13.52 MB capacity, 11.83 MB ( 87%) used, 1.61 MB ( 12%) free, 16 bytes ( <1%) waste, 88.12 KB ( <1%) overhead, deallocated: 541 blocks with 377.14 KB
Both: 4788 chunks, 118.80 MB capacity, 115.84 MB ( 98%) used, 2.66 MB ( 2%) free, 3.77 KB ( <1%) waste, 299.25 KB ( <1%) overhead, deallocated: 4359 blocks with 2.41 MB
Virtual space:
Non-class space: 108.00 MB reserved, 106.12 MB ( 98%) committed
Class space: 1.00 GB reserved, 13.62 MB ( 1%) committed
Both: 1.11 GB reserved, 119.75 MB ( 11%) committed
Chunk freelists:
Non-Class:
specialized chunks: 1, capacity 1.00 KB
small chunks: 192, capacity 768.00 KB
medium chunks: (none)
humongous chunks: (none)
Total: 193, capacity=769.00 KB
Class:
specialized chunks: 1, capacity 1.00 KB
small chunks: 3, capacity 6.00 KB
medium chunks: (none)
humongous chunks: (none)
Total: 4, capacity=7.00 KB
Waste (percentages refer to total committed size 119.75 MB):
Committed unused: 200.00 KB ( <1%)
Waste in chunks in use: 3.77 KB ( <1%)
Free in chunks in use: 2.66 MB ( 2%)
Overhead in chunks in use: 299.25 KB ( <1%)
In free chunks: 776.00 KB ( <1%)
Deallocated from chunks in use: 2.41 MB ( 2%) (4359 blocks)
-total-: 6.32 MB ( 5%)
MaxMetaspaceSize: 17179869184.00 GB
InitialBootClassLoaderMetaspaceSize: 4.00 MB
UseCompressedClassPointers: true
CompressedClassSpaceSize: 1.00 GB
Non-Class: 3378 chunks, 105.27 MB capacity, 104.01 MB ( 99%) used, 1.05 MB ( <1%) free, 3.76 KB ( <1%) waste, 211.12 KB ( <1%) overhead, deallocated: 3818 blocks with 2.04 MB
Class: 1410 chunks, 13.52 MB capacity, 11.83 MB ( 87%) used, 1.61 MB ( 12%) free, 16 bytes ( <1%) waste, 88.12 KB ( <1%) overhead, deallocated: 541 blocks with 377.14 KB
Both: 4788 chunks, 118.80 MB capacity, 115.84 MB ( 98%) used, 2.66 MB ( 2%) free, 3.77 KB ( <1%) waste, 299.25 KB ( <1%) overhead, deallocated: 4359 blocks with 2.41 MB
Virtual space:
Non-class space: 108.00 MB reserved, 106.12 MB ( 98%) committed
Class space: 1.00 GB reserved, 13.62 MB ( 1%) committed
Both: 1.11 GB reserved, 119.75 MB ( 11%) committed
Chunk freelists:
Non-Class:
specialized chunks: 1, capacity 1.00 KB
small chunks: 192, capacity 768.00 KB
medium chunks: (none)
humongous chunks: (none)
Total: 193, capacity=769.00 KB
Class:
specialized chunks: 1, capacity 1.00 KB
small chunks: 3, capacity 6.00 KB
medium chunks: (none)
humongous chunks: (none)
Total: 4, capacity=7.00 KB
Waste (percentages refer to total committed size 119.75 MB):
Committed unused: 200.00 KB ( <1%)
Waste in chunks in use: 3.77 KB ( <1%)
Free in chunks in use: 2.66 MB ( 2%)
Overhead in chunks in use: 299.25 KB ( <1%)
In free chunks: 776.00 KB ( <1%)
Deallocated from chunks in use: 2.41 MB ( 2%) (4359 blocks)
-total-: 6.32 MB ( 5%)
MaxMetaspaceSize: 17179869184.00 GB
InitialBootClassLoaderMetaspaceSize: 4.00 MB
UseCompressedClassPointers: true
CompressedClassSpaceSize: 1.00 GB
Wie müsste ich das ganze konfigurieren damit es eben alles regelmäßig wieder aufräumt?
Viele Grüße