garbage-collection

Tuning JVM (GC) for high responsive server application

I am running an application server on Linux 64bit with 8 core CPUs and 6 GB memory. The server must be highly responsive. After some inspection I found that the application running on the server creates rather a huge amount of short-lived objects, and has only about 200~400 MB long-lived objects(as long as there is no memory leak) Aft...

destructors on gc-ed lua objects

Hi! I know that Lua is gc-ed. I know that Lua can deal with c objects via userdata. Here is my question: is there anyway to register a function so that it's called when a C userdata object is gc-ed by lua? [Basically a destructor]. Thanks! ...

Java without gc - io

Hi Guys I would like to run a Java program with garbage collection switched off. Managing memory in my own code is not so difficult. However the program needs quite a lot of I/O. Is there any way (short of using JNI for all I/O operations) that I could achieve this using pure Java? Thanks Daniel ...

What is root reference ?

class GCTest { static Object r1; static void Main() { r1 = new Object(); Object r2 = new Object(); Object r3 = new Object(); System.GC.Collect(); // what can be reclaimed here ? r1 = null; r3.ToString(); System.GC.Collect(); // what can be reclaimed here ? }...

Counting number of GC cleanups on an object

How do I keep a count of the number of times that objects of a specific class (type?) are getting disposed in the lifetime of my application. Imagine I have a class A, now, I want to count how many times the objects of A get collected by the GC. I hope I am phrasing this right because I was asked this in an interview today and the answ...

Why is free() not allowed in garbage-collected languages?

I was reading the C# entry on Wikipedia, and came across: Managed memory cannot be explicitly freed; instead, it is automatically garbage collected. Why is it that in languages with automatic memory management, manual management isn't even allowed? I can see that in most cases it wouldn't be necessary, but wouldn't it come in hand...

Eclipse: Garbage Collector Button

What happens when I press the "Run Garbage Collector" button in Eclipse? Does it just call System.gc()? ...

C# garbage collector cross reference

Will garbage collector free resources for cross referenced object/class, which is no longer referenced from main program. For example - class class1 { class2 m_RefClass2; } class class2 { class1 m_RefClass1; } class class3 { public class3() { class1 obj1 = new class1(); class2 obj2 = new class2(); ...

Tuning garbage collections for low latency

I'm looking for arguments as to how best to size the young generation (with respect to the old generation) in an environment where low latency is critical. My own testing tends to show that latency is lowest when the young generation is fairly large (eg. -XX:NewRatio <3), however I cannot reconcile this with the intuition that the large...

Can .NET Task instances go out of scope during run?

If I have the following block of code in a method (using .NET 4 and the Task Parallel Library): var task = new Task(() => DoSomethingLongRunning()); task.Start(); and the method returns, will that task go out of scope and be garbage collected, or will it run to completion? I haven't noticed any issues with GCing, but want to make sur...

Peculiar JRE behaviour running RMI server under load, should I worry?

I've been developing a minimalistic Java rich client CRUD application framework for the past few years, mostly as a hobby but also actively using it to write applications for my current employer. The framework provides database access to clients either via a local JDBC based connection or a lightweight RMI server. Last night I started a...

System.identityHashCode() and compacting garbage collectors

Possible Duplicate: How does the JVM ensure that System.identityHashCode() will never change? I was just wondering how System.identityHashCode() is able to always yield the same result for a given object, even if the garbage collector moves it around in memory. Does every object have an additional invisible field storing its i...

GC output clarification

I'm running a java application with the following settings: -XX:+CMSParallelRemarkEnabled -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCApplicationConcurrentTime -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -XX:+PrintHeapAtGC -XX:+PrintTenuringDistribution I'm not sure ho...

Java HotSpot 1.6 VM, Garbage Collection - Scary PermGen

Hi, My app shows rising 'Old Generation'/'Tenured Generation' size, and when this reaches the max limit for 'Old Gen', then suddenly PermGen size increases. Here are my generation sizings: -Xmx1200m -Xms1200m -Xmn450m -XX:MaxPermSize=600m -XX:+UseParallelGC This is on 32 bit Fedora so can't have a bigger heap than this. The app is n...

Using WeakReference to resolve issue with .NET unregistered event handlers causing memory leaks.

The problem: Registered event handlers create a reference from the event to the event handler's instance. If that instance fails to unregister the event handler (via Dispose, presumably), then the instance memory will not be freed by the garbage collector. Example: class Foo { public event Action AnEvent; pu...

iPhone, No Garbage Collection: What About MonoTouch?

It's well known that Apple does not provide automatic garbage collection on the iPhone to prolong battery life. Yet MonoTouch apps, which reportedly run perfectly on the iPhone (and many are sold through the AppStore, therefore are approved by Apple), do have automatic garbage collection. Is this automatic garbage collection, or does M...

Is eclipse's Garbage Collector different than the default?

From questions posted here and an old one of mine I have created the impression that you cannot explicitly run the Java Garbage Collector whenever you please. If you call it, you simply instruct the system to call it whenever it can or thinks is appropriate. But in eclipse, if you press the "Run Garbage Collector" button you see an imm...

Closing some instances of an app, increases Gen-2 Garbage Collection Heap?

We're in the middle of debugging some memory issues. We were watch 5 instances of the same app. We stopped 3. The Gen2 Heap size went from about 5M to almost 10M, and the Gen0 and Gen1 heap sizes changed insignificantly. This is the exact opposite of what I'd expect. I expected it to reduce in size, and would never expect it to incre...

Lock statement vs Monitor.Enter method.

I suppose it is an interesting code example. We have a class, let's call it Test with Finalize method. In Main method here is two code blocks where i am using lock statement and Monitor.Enter call. Also i have two instances of class Test here. The experiment is pretty simple - nulling Test variable within locking block and try to collec...

Is there a way to do WeakList (think WeakReference) in CLR?

A List does not work in the way that I want. The way that I want is that WeakReferences are automatically removed from the list when the object they weakly reference is garbage collected. ConditionalWeakTable does not do what I want either, because although its keys and values are weakly referenced and collectable, you cannot enumerate ...