garbage-collection

Does the Garbage Collector destroy temporarily unreferenced objects during async calls in .NET?

Imagine that I will make an async call in .NET, i.e. HttpWebRequest.BeginGetResponse, and the HttpWebRequest object isn't referenced at a broader scope. Will the Garbage Collector destroy it and cause problems? Example code: using System; using System.Net; public class AsyncHttpWebRequest { void Main() { var Request = ...

What alternatives to Hans Boehm GC are out there for small devices?

I'd like to use a virtual machine like NekoVM into a small device but to build it, it requires Boehm GC, however there is no port of that GC to that small device so I was wondering if there is any alternative to it, something that could be done exclusively with C code? ...

MATLAB Java referencing problem

I have a MATLAB class which contains a reference to a java object classdef MyClass properties j = myJavaClass end methods ... end end and after I use it (using clear, scope exit or explicitly setting myClass = 0; ) the java object is still alive - even after calling Runtime.gc. I see in the dump that the object is still i...

Garbage collection behavior with isolated cyclic references?

If I have two objects on the heap referring to each other but they are not linking to any reference variable then are those objects eligible for garbage collection? ...

How can I find memory leaks in long-running Perl program?

Perl uses reference counting for GC, and it's quite easy to make a circular reference by accident. I see that my program seems to be using more and more memory, and it will probably overflow after a few days. Is there any way to debug memory leaks in Perl? Attaching to a program and getting numbers of objects of various types would be a...

Why is it "impossible" to implement garbage collection in C because of weak typing?

I was told by a rather smart person that you cannot implement garbage collection in C because of it's weakly typed. The basic idea seems to be that C gives you too much freedom. He mentioned casting pointers without type checking... I don't really grok the idea. Can someone give me an explanation and possibly a code sample of why this w...

When are ASP.NET MVC Controllers garbage collected?

Once a controller object is created when does it become available for garbage collection? ...

Does assigning objects to null in Java impact garbage collection?

Does assigning an unused object to null in Java improve the garbage collection process in any measurable way? My experience with Java (and C#) has taught me that is often counter intuitive to try and outsmart the virtual machine or JIT, but I've seen co-workers use this method and I am curious if this is a good practice to pick up or on...

Are static fields open for garbage collection?

Given an hypothetical utility class that is used only in program setup: class MyUtils { private static MyObject myObject = new MyObject(); /*package*/static boolean doStuff(Params... params) { // do stuff with myObject and params... } } will myObject be garbage collected when it is no longer being used, or will it stic...

In the Dispose(bool) method implementation, Shouldn't one set members to null?

None of the guides/notes/articles that discuss IDisposable pattern suggest that one should set the internal members to null in the Dispose(bool) method (especially if they are memory hogging beasts). I've come to realize the importance of it while debugging an internal benchmark tool. What used to happen was that, there was this buffer ...

How to cause soft references to be cleared in Java?

I have a cache which has soft references to the cached objects. I am trying to write a functional test for behavior of classes which use the cache specifically for what happens when the cached objects are cleared. The problem is: I can't seem to reliably get the soft references to be cleared. Simply using up a bunch of memory doesn't do...

How to reduce memory usage in a Haskell app?

I am new to functional programming, and now learn Haskell. As an exercise I decided to implement the explicit Euler method for 1D linear diffusion equation. While the code below works correctly, I am not happy about its performance. In fact, I am concerned with memory consumption. I believe that it is related to lazy evaluation, but cann...

Is there a way to retrieve a C# app's current memory usage?

I am automating some profiling tasks and want to log heap space and generation sizes real-time. The profiling API seems awfully complicated for what I need, and it seems to listen in on individual allocations and collections, which isn't that important to me. Profiling tools are a great help of course, but I was looking for a more flex...

Garbage collection in C++?

What garbage collectors are there available for C++? Are you using any of them? With what results? ...

Can you get basic GC stats in Java?

I would like to have some long-running server applications periodically output general GC performance numbers in Java, something like the GC equivalent of Runtime.freeMemory(), etc. Something like number of cycles done, average time, etc. We have systems running on customer machines where there is a suspicion that misconfigured memory ...

Memory Allocation/Deallocation Bottleneck?

How much of a bottleneck is memory allocation/deallocation in typical real-world programs? Answers from any type of program where performance typically matters are welcome. Are decent implementations of malloc/free/garbage collection fast enough that it's only a bottleneck in a few corner cases, or would most performance-critical softw...

Turning off the D garbage collector

I'm a C++ programmer thats considering using D for a personal project I want to play around with. I was wondering if there's a way to completely disable the garbage collector, and what the risks are of doing so. I know I can manage my own memory by overriding new and delete to use malloc and free, but if I did that I'd rather the gar...

Does it help GC to null local variables in Java

I was 'forced' to add myLocalVar = null; statement into finally clause just before leaving method. Reason is to help GC. I was told I will get SMS's during night when server crashes next time, so I better did it :-). I think this is pointless, as myLocalVar is scoped to method, and will be 'lost' as soon as method exits. Extra nulling j...

In C#, where should I keep my timer's reference?

The documentation of System.Threading.Timer says that I should keep a live reference for it to avoid it being garbage collected. But where should I do that? My main is very simple that I don't know where to keep the reference: class Program { static void Main() { new System.Threading.Thread(myThreadStart).Start(); ne...

When is it acceptable to call GC.Collect?

The general advise is that you should not call GC.Collect from your code, but what are the exceptions to this rule? I can only think of a few very specific cases where it may make sense to force a garbage collection. One example that springs to mind is a service, that wakes up at intervals, performs some task, and then sleeps for a lo...