garbage-collection

Class Unloading in Java's G1 Garbage Collector (G1GC)

半腔热情 提交于 2020-01-01 05:08:48
问题 In Java 6 we used to use the following GC configuration to prevent Perm Gen OutOfMemoryException after several redeployments of our app: -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled We're moving to Java 7 and want to use the new G1 GC, which from what I've read, moves the classes from the PermGen in Java memory to native memory. Is there some flag to enable unloading unused classes? 回答1: The G1 performs the class unloading during a Full GC, so you do not need to specify any

GC Behavior and CLR Thread Hijacking

夙愿已清 提交于 2020-01-01 04:18:22
问题 I was reading about the GC in the book CLR via C# , specifically about when the CLR wants to start a collection. I understand that it has to suspend the threads before a collection occurs, but it mentions that it has to do this when the thread instruction pointer reaches a safe point. In the cases where it's not in a safe point, it tries to get to one quickly, and it does so by hijacking the thread (inserting a special function pointer in the thread stack). That's all fine and dandy, but I

getImageData - Web workers - How can I reduce garbage collection?

拈花ヽ惹草 提交于 2020-01-01 03:38:07
问题 I've got a sample web-worker canvas update script running, but I've noticed it stalls every few seconds for about 200ms. The usual loop time is around 15ms. I'm guessing this is garbage collection - it looks like it from the profiler. http://codepen.io/SarahC/pen/bgBoMM I think it is in this function: function nextFrame(){ timeChart.start(); workersWorking = workerCount; var stripHeight = ~~( h / workerCount ); for(var i = 0; i < workerCount; i++){ var localImageData = ctx.getImageData(0,

Finding Memory Usage in Java

百般思念 提交于 2020-01-01 03:30:18
问题 Following is the scenario i need to solve. I have struck with two solutions. I need to maintain a cache of data fetched from database to be shown on a Swing GUI. Whenever my JVM memory exceeds 70% of its allocated memory, i need to warn user regarding excessive usage. And once JVM memory usage exceeds 80%, then i have to halt all the database querying and clean up the existing cache fetched as part of the user operations and notifying the user. During cleanup process, i will manually handle

gdb: set a breakpoint for a SIGBUS handler

北城以北 提交于 2020-01-01 02:43:32
问题 I'm trying to debug a simple stop-and-copy garbage collector (written in C) using GDB. The GC works by handling SIGBUS. I've set a breakpoint at the top of my SIGBUS signal handler. I've told GDB to pass SIGBUS to my program. However, it doesn't appear to work. The following program (explained inline) shows the essence of my problem: #include <stdio.h> #include <sys/mman.h> #include <assert.h> #include <signal.h> #define HEAP_SIZE 4096 unsigned long int *heap; void gc(int n) { signal(SIGBUS,

Suppressing C# garbage collection

本秂侑毒 提交于 2020-01-01 02:31:07
问题 My application allocates a large amount of memory (millions of small objects totaling several gigabytes) and holds onto it for a long time. Is .NET wasting time checking through all of this data to do GC on it? How often does the Gen 2 GC occur (the one that checks all objects)? Is there any way to reduce it's frequency or temporarily suppress it from occurring? I know exactly when I am ready for a large amount of memory to be collected, is there any way to optimize for that? I am currently

Are anonymous listeners incompatible with weak references?

天涯浪子 提交于 2020-01-01 02:08:33
问题 I was reading this question that just got asked: Avoid memory leaks in callbacks? And I was quite confused, until someone answered the following: "The problem with this approach is you cannot have a listener which is only referenced in the collection as it will disappear randomly (on the next GC)" Am I correct in my understanding that using a weak references, like when stored in a WeakHashMap , is incompatible with anonymous listeners? I typically pass listeners like this: public static void

What mechanism JVM use to block threads during stop-the-world pause

情到浓时终转凉″ 提交于 2020-01-01 01:32:33
问题 I heard this question on an interview and couldn't provide an answer. Later I searched thru the internet and still didn't find an answer. Can anybody tell me how JVM stops threads during stop-the-world pause when collecting garbage and how it run them again. 回答1: For HotSpot and OpenJDK at least, the JVM uses safe points to stop the application's flow in each thread, either introduced in the JITed code or by changing the bytecode mappings for interpreted code (see this post by Alexey Ragozin

What mechanism JVM use to block threads during stop-the-world pause

痴心易碎 提交于 2020-01-01 01:32:10
问题 I heard this question on an interview and couldn't provide an answer. Later I searched thru the internet and still didn't find an answer. Can anybody tell me how JVM stops threads during stop-the-world pause when collecting garbage and how it run them again. 回答1: For HotSpot and OpenJDK at least, the JVM uses safe points to stop the application's flow in each thread, either introduced in the JITed code or by changing the bytecode mappings for interpreted code (see this post by Alexey Ragozin

Is there a way to schedule a Full Garbage Collection in Java? [duplicate]

怎甘沉沦 提交于 2019-12-31 20:32:46
问题 This question already has answers here : How to force garbage collection in Java? (22 answers) Closed 5 years ago . I have an application that's running on a 24x6 schedule. Currently, after running for a few days, a Full GC is performed automatically - and usually during a busy part of the day, which negatively impacts user response times. What I'd like to do is force a Full GC - perhaps at midnight each night, during very low usage times - to prevent it from happening during the day. I've