garbage-collection

How to properly clean up interop objects in C#

This is a follow on question to How to properly clean up excel interop objects in c#. The gyst is that using a chaining calls together (eg. ExcelObject.Foo.Bar() ) within the Excel namespace prevents garbage collection for COM objects. Instead, one should explicitly create a reference to each COM object used, and explicitly release the...

Garbage collection of Core Foundation objects

Running the static analyzer on this piece of code: - (id) readForeignPref { CFPropertyListRef matchStyle = CFPreferencesCopyAppValue(CFSTR("PBXFindMatchStyle"), CFSTR("com.apple.Xcode")); return [(id)matchStyle autorelease]; } yields the following warning: Call to function 'CFPreferencesCopyAppValue' returns a Core Foundation ob...

Tempfile and Garbage Collection

I have this command in a Rails controller open(source) { |s| content = s.read } rss = RSS::Parser.parse(content, false) and it is resulting in temporary files that are filling up the (scarce) disk space. I have examined the problem to some extent and it turns out somewhere in the stack this happens: io = Tempfile.new('open-uri')...

Clearing controls from FlowLayoutPanel not calling destructors?

Sorry if I'm missing something obvious, but I'm trying to clear the controls (a series of user controls) from a FlowLayoutPanel - (panelName).Controls.Clear();. Unfortunately this doesn't seem to be calling the destructors for the objects on the panel - the User Objects column in the task manager just keeps going up and up, until it hits...

ASP MVC: When is IController Dispose() called?

Hey, all! I'm going through a big refactoring / speed tweaking of one of my larger MVC apps. It has been deployed to production for a few months now, and I was starting to get timeouts waiting for connections in the connection pool. I have tracked the issue down to the connections not getting disposed properly. In light of that, I ha...

What means the error-message 'java.lang.OutOfMemoryError: GC overhead limit exceeded' in Java?

I get this errormessage as I execute my JUnit-Tests: java.lang.OutOfMemoryError: GC overhead limit exceeded I know OutOfMemoryError, but what does GC overhead limit mean, and how can I exceed this? EDIT: I resolved the problem, but thanks to your answers I learned something new about the JVM. ...

Heap Dump Root Classes

We have production system going into infinite loop of full gc and memory drops form 8 gigs to like 1 MB in just 2 minutes. After taking heap dump it tells me there an is an array of java.lang.Object ([Ljava.lang.Object) with millions of java.lang.String objects having same String taking 99% of heap. But it doesn't tell me which class i...

Mixing Erlang and Haskell

If you've bought into the functional programming paradigm, the chances are that you like both Erlang and Haskell. Both have purely functional cores and other goodness such as lightweight threads that make them a good fit for a multicore world. But there are some differences too. Erlang is a commercially proven fault-tolerant language ...

Disposing of System.Drawing Objects

Is it necessary to manually manage the lifetime of System.Drawing objects? Currently I am employing 'using' statements to minimise the lifespan of Brushes and other Drawing objects e.g. using ( Brush br = new SolidBrush( color ) ) { // Do something with br } Is this necessary or is it safe to let the garbage collector work its ma...

When would dispose method not get called?

I was reading this article the other day and was wondering why there was a Finalizer along with the Dispose method. I read here on SO as to why you might want to add Dispose to the Finalizer. My curiousity is, when would the Finalizer be called over the Dispose method itself? Is there a code example or is it based on something happeni...

Why should you have to dispose() a java.awt.Window that goes out of scope?

One of the memory leaks I've discovered in our application is the java.awt.Window.allWindows private static field, which keeps track of every Window instantiated. We have dialog boxes that are created, used, and then forgotten, and the expectation was that these would go away and be garbage collected. This private field keeps them in s...

How an uninitialised variable gets a garbage value?

Possible duplicate Uninitialized values being initialized? When we create a variable and don't initialize it, then some (random) number called garbage value is assigned to it. How this value is assigned to the variable? What is whole concept/mechanism behind this? Does this happen only in C? ...

Garbage collection vs. non garbage collection programming languages

So if I understand well, Garbage collection automatically deallocates objects that are not used by the program anymore. like the garbage collector in java. I hear in languages like C that don't support garbage collection the programs can have memory leaks and subsequently exhaust the memory. So what are the errors that programmer make ...

objc_startCollectorThread() implicit declaration warning

I'm trying to work through Apple's CoreData Utility Tutorial. It asks me to create a 'Foundation Tool' project in the 'Command Line Utility' section. In XCode 3.2, I only found a 'Command Line Tool' section with a 'Foundation' type in the 'New Project' wizard. So I created the 'Command Line Tool' 'Foundation' type project, and added t...

Session state and garbage collection in IIS6 for Classic ASP

This is a bit of a throwback question, and probably relatively fundamental, but I'm at a loss. How does IIS manage Classic ASP session state? We have an app that stores user information in session, and when many users are using the app, it seems to be recycling session for users, even though the "expire period" has not elapsed. We su...

sample code or projects using simple reference counter in C

I am wondering how difficult it would be to integrate a reference counting (or other managed memory) regime for managing some of my struct libraries in C. What sample code would you recommend I look at? ...

The power of .NET without the garbage collection?

I love C# because the powerful features of the .NET framework make it so easy to develop for Windows. However I also love standard C++ primarily because it gives me fine-tuned control over memory management. Is there a way to have the best of both worlds? Are there C++ libraries that can compete with the rich set of libraries in the .NET...

How do you free system ram when creating and disposing user controls.

I have a c# application that is composed of various screens which is each a respective user control. The application requires a lot of switching between the various screens and is also graphic intensive. Each control is disposed once the next control is invoked and the garbage collector is called to release the system resources. The thin...

MATLAB's Garbage Collector?

What is your mental model of it? How is it implemented? Which strengths and weaknesses does it have? MATLAB GC vs. Python GC? I sometimes see strange performance bottlenecks when using MATLAB nested functions in otherwise innocuously looking code, I am sure it is because of GC. Garbage Collector is an important part of VM and Mathworks ...

CUDA global memory deallocation issues in .NET

I have a class (see example bellow) which acts as a .NET wrapper for a CUDA memory structure, allocated using cudaMalloc() and referenced using a member field of type IntPtr. (The class uses DllImport of a native C DLL which wraps various CUDA functionality.) The dispose methods checks if the pointer is IntPtr.Zero and if not calls cuda...