garbage-collection

Cost to GC of using weak references in C#?

In another question, Stephen C says: A second concern is that there are runtime overheads with using weak references. The obvious costs are those of creating weak references and calling get on them. A less obvious cost is that significant extra work needs to be done each time the GC runs. So what exactly is the cost t...

How does the CLR (.NET) internally allocate and pass around custom value types (structs)?

Question: Do all CLR value types, including user-defined structs, live on the evaluation stack exclusively, meaning that they will never need to be reclaimed by the garbage-collector, or are there cases where they are garbage-collected? Background: I have previously asked a question on SO about the impact that a fluent...

Weak References and Disposable objects.

In C# it is possible to create weak references to objects as described here: WeakReference Class In .net some classes also implement the IDisposable interface. Calling the Dispose method of this interface is performed to manually dispose of any managed or unmanaged resources currently being held onto. An example might be a Bitmap objec...

Why does this code sample produce a memory leak?

In the university we were given the following code sample and we were being told, that there is a memory leak when running this code. The sample should demonstrate that this is a situation where the garbage collector can't work. As far as my object oriented programming goes, the only codeline able to create a memory leak would be ite...

When log shows a lot of GC hits, what code change shall we need?

When log shows a lot of Garbage Collection hits, what code change shall we need? Do we need to free some objects? Will we speed up the code with object reusal? EDIT I run this code against a lot of names: public static String removeAccents(String s) { if (s == null) return null; StringBuilder sb = new Stri...

C# - free all resources used by an object

Is there some way to free all resources used by certain object ? If not, why wouldn't I use the GC.Collect() method ? ...

Meaning of message "operations coalesced during safepoint"

A java app runs with the following flag: -XX:+PrintSafepointStatistics, and then produces the following line on the standard output console: 2 VM operations coalesced during safepoint Anyone cares to explain what this mean ? More generally - is there a Java reference manual somewhere detailling all JVM flags, their use and, most impo...

Where unmanaged resources are allocated.

Hello all, I am not a comp science guy. Managed resources are allocated on the heap. But I would like to know where unmanaged resources are allocated. If unmanaged resources are also allocated on the heap, is it the same heap used by managed resources or a different one? Thanks in advance. Harsha ...

How do I get .NET to garbage collect aggressively?

I have an application that is used in image processing, and I find myself typically allocating arrays in the 4000x4000 ushort size, as well as the occasional float and the like. Currently, the .NET framework tends to crash in this app apparently randomly, almost always with an out of memory error. 32mb is not a huge declaration, but if...

Duration of Excessive GC Time in "java.lang.OutOfMemoryError: GC overhead limit exceeded"

Occasionally, somewhere between once every 2 days to once every 2 weeks, my application crashes in a seemingly random location in the code with: java.lang.OutOfMemoryError: GC overhead limit exceeded. If I google this error I come to this SO question and that lead me to this piece of sun documentation which expains: The parallel coll...

Use PermGen space or roll-my-own intern method?

I am writing a Codec to process messages sent over TCP using a bespoke wire protocol. During the decode process I create a number of Strings, BigDecimals and dates. The client-server access patterns mean that it is common for the client to issue a request and then decode thousands of response messages, which results in a large number o...

Does JavaScript have an equivalent to Perl's DESTROY method?

Is there any method that is called or event that is dispatched right before an Element is cleaned up by the JavaScript garbage collector? In Perl I would write: package MyObj; sub new {bless {}} sub DESTROY {print "cleaning up @_\n"} and then later: { my $obj = MyObj->new; # do something with obj } # scope ends, and ass...

Does invoking System.gc() in java suggest garbage collection of the tenured generation as well as the young generation?

When invoking System.gc() in java (via JMX), it will dutifully (attempt to) clean the young generation. This generally works very well. I have never seen it attempt to clean the tenured generation, though. This leads me to two questions: Can the tenured generation even be collected (i.e. is there actually garbage in this generation, or...

Is there any configuration for the garbage collector?

As I understand it, the garbage collector adjusts isself as the application runs, the threshhold used for example, when objects on the managed heaps are collected is adjusted (according to MSDN) over time. If an application crashes, does the runtime remember it's previous garbage collection 'settings' or any other settings? ...

.Net Finalizer Order / Semantics in Esent and Ravendb

Help me understand. I've read that "The time and order of execution of finalizers cannot be predicted or pre-determined" Correct? However looking at RavenDB source code TransactionStorage.cs I see this ~TransactionalStorage() { try { Trace.WriteLine( "Disposing esent resources from finalizer! You should call TransactionalStorage....

How do i stop the android garbage collector? Is it possible?

Is there any way to stop the garbage collector for some time? ...

How does the Garbage-First Garbage Collector work?

Hi Can someone explain how the G1 Garbage Collector works please? I haven't been able to find any comprehensive, easy-to-understand descriptions anywhere yet. Thanks ...

If you stick to standard coding in .NET, is there reason to manually invoke the GC or run finalizers ?

If you stick to managed code and standard coding (nothing that does unconventional things withe CLR) in .NET, is there any reason to manually invoke the GC or request to run finalizers on unreferenced objects? The reason I ask is thaty I have an app that grows huge in Working Memory set. I'm wondering if calling System.GC.Collect(); ...

Analysing objects generated by a Java application in between GCs.

Is there a tool which could be used to analyse the objects being created between two separate garbage collection run (= number of objects created and their type) ? Heapdumps dont really work here as they perform a GC when they're invoked (or at least that's what I observed everytime so far), and I want to see which objects are collected...

JVM CMS Garbage Collecting Issues

I'm seeing the following symptoms on an application's GC log file with the Concurrent Mark-Sweep collector: 4031.248: [CMS-concurrent-preclean-start] 4031.250: [CMS-concurrent-preclean: 0.002/0.002 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 4031.250: [CMS-concurrent-abortable-preclean-start] CMS: abort preclean due to time 4036...