Skip to content

Instantly share code, notes, and snippets.

@kimchy
Created July 12, 2011 19:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kimchy/1078717 to your computer and use it in GitHub Desktop.
Save kimchy/1078717 to your computer and use it in GitHub Desktop.
native memory leak with GarbageCollectorMXBean#getLastGcInfo
import java.lang.management.GarbageCollectorMXBean;
import java.lang.management.ManagementFactory;
import java.util.List;
public class TestMemoryLeak {
public static void main(String[] args) throws Exception {
while (true) {
List<GarbageCollectorMXBean> gcMxBeans = ManagementFactory.getGarbageCollectorMXBeans();
for (GarbageCollectorMXBean gcMxBean : gcMxBeans) {
((com.sun.management.GarbageCollectorMXBean) gcMxBean).getLastGcInfo();
}
}
}
}
@tobiasbrenner
Copy link

@kimchy: do you have a workaround for this? Can you confirm such kind of bugs for the other MXBeans, too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment