garbage-collection

Handle PrintGCApplicationStoppedTime flag in java 9

99封情书 提交于 2020-01-10 04:09:25
问题 My application is using gc flag "PrintGCApplicationStoppedTime" but when am running it with Java 9 it is failing with following error: Unrecognized VM option 'PrintGCApplicationStoppedTime' Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit. This post indicate that option is deprecated but is there any alternative for the information printed by his flag or this information is no longer available? 回答1: Few things to know there: First,

Examples of forcing freeing of native memory direct ByteBuffer has allocated, using sun.misc.Unsafe?

你。 提交于 2020-01-09 12:52:53
问题 JDK provides abillity to allocate so-called direct ByteBuffers, where memory is allocate outside of Java heap. This can be beneficial since this memory is not touched by garbage collector, and as such does not contribute to GC overhead: this is a very useful for property for long-living things like caches. However, there is one critical problem with existing implementation: underlying memory is only allocated asynchronously when the owning ByteBuffer is garbage-collected; there is no way to

Java new String and new StringBuilder in heap behavior

元气小坏坏 提交于 2020-01-09 11:29:47
问题 Does the String pool reside on the heap? If yes, are String literals eligible for garbage collection? When using new String("abc") , we know that it creates an object on the heap and places the String literal in the String pool. So my 2nd question is: Does new StringBuilder("abc") behave the same way as new String("abc") ? If yes, how does StringBuilder manipulate the String literal inside the String pool? 回答1: You are confusing compile time, load time, and runtime. A string literal is added

Find all references to an object in python

心已入冬 提交于 2020-01-09 09:31:28
问题 What is a good way to find all of the references to an object in python? The reason I ask is that it looks like we have a "memory leak". We are uploading image files to the server from a web browser. Each time we do this, the memory usage on the server goes up proportionately to the size of the file that was just uploaded. This memory is never getting released by the python garbage collection, so I'm thinking that there are probably stray references pointing to the image data that are not

When does System.gc() do something?

情到浓时终转凉″ 提交于 2020-01-08 08:51:09
问题 I know that garbage collection is automated in Java. But I understood that if you call System.gc() in your code that the JVM may or may not decide to perform garbage collection at that point. How does this work precisely? On what basis/parameters exactly does the JVM decide to do (or not do) a GC when it sees System.gc() ? Are there any examples in which case it's a good idea to put this in your code? 回答1: In practice, it usually decides to do a garbage collection. The answer varies depending

Java HeapDumps indicate that used Heap Size is 30% smaller than actual heap definition after OutOfMemory exceptions

▼魔方 西西 提交于 2020-01-07 07:43:11
问题 I have a handful of heap dumps that I am analyzing after the JVM has thrown OutOfMemory exceptions. I'm using Hotspot JDK 1.7 (64bit) on a Windows 2008R2 platform. The application server is a JBoss 4.2.1GA, launched via the Tanuki Java Service Wrapper. It is launched with the following arguments: wrapper.java.additional.2=-XX:MaxPermSize=256m wrapper.java.initmemory=1498 wrapper.java.maxmemory=3000 wrapper.java.additional.19=-XX:+HeapDumpOnOutOfMemoryError which translate to: -Xms1498m

Tasks not finishing before process end

冷暖自知 提交于 2020-01-07 04:52:07
问题 In my code in the main thread I call a 3rd party API. For each result from the API I call 2 async tasks. Sometimes all works perfectly, sometimes not all async tasks run. I suppose that when the main thread finishes, the garbage collector kills all my other tasks that run in the background. Is there any way to tell garbage collector not to kill the background services when the main thread finishes? The code is like this: for (int i = 0; i < 1000; i++) { var demo = new AsyncAwaitTest(); demo

OutOfMemoryError: GC overhead limit exceeded android

China☆狼群 提交于 2020-01-07 03:48:29
问题 In android studio 1.5.1 just by moving the source code from one system to another and Even though the clean build is successful but while the code is run I am getting this kind of error java.lang.OutOfMemoryError: GC overhead limit exceeded Error:Execution failed for task ':app:dexDebug'. > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-7-openjdk-amd64/bin/java'' finished with non-zero exit value 3 I added the

Log4j Logger garbage collection?

半世苍凉 提交于 2020-01-06 15:51:37
问题 Is there a way to force a Log4j Logger to be released/garbage collected? In general, does Log4j "hang on" to Logger references in some static collection? I see the Logger.shutdown() method, which is deprecated and refers to LoggerManager.shutdown() , which doesn't sound like it addresses a single Logger instance. 回答1: You could take a look at the log4j source code yourself. Based on a quick trawl, I think the answers are: Is there a way to force a Log4j Logger to be released/garbage collected

Java OutOfMemoryError: GC overhead limit exceeded when processing large text file - cant figure out how to improve performance

房东的猫 提交于 2020-01-06 15:16:59
问题 Note: I browsed all topics on this problem and I understand that it's often down to JVM settings and efficient coding but I dont know how to improve even more. I am processing a large text file (1GB) of CAIDA network topologies, this is basically a dump of the entire Internet IPv4 topology. Each line is of format "node continent region country city latitude longitude" and I need to filter all the duplicate nodes (e.g. each node with the same lat/longitude). I assign a unique name to all nodes