garbage-collection

What's wrong with mark-and-sweep GCs?

I'm reading Steve Yegge's "Dynamic Languages Strike Back" talk, and in it he sort of criticizes mark-and-sweep GCs (about 5-10 percent through that link, the "Pigs attempt's to fly" slide) What's wrong with them? ...

My program crashes when GC perform garbage collection

My program has a trouble: When GC perform garbage collection,my program always crashes at a function,which is called by main flow several times before crashing and the first line of this function is GC.Collect().The function main action is sending some bytes to serial port and receiving some bytes from the same serial port( Both send...

Strategies for debugging Objective-C Garbage Collection Crash

I have a pretty frustrating crasher that is impacting a small subset of my users. From my analysis it seems to be isolated to PowerPC users running 10.5. When the garbage collector runs in the background, it will silently kill my application. Here's the relevant snippet from the crashlog. Exception Type: EXC_BREAKPOINT (SIGTRAP) ...

OutOfMemory exception

Hi, 1) What are the possible reasons of OutofMemory exception. 2) Memory allocations should be handled by GC. 3) How much memory is allocated/Available to normal .Net/C# application In our application it comes at different places like Stream.ReadToEnd() and DataTable.WriteXml(Memory stream) function. *) Envoirment is .Net C# ...

Javascript: know when an object will be garbaged

Hi all, is there a way to know when an object will be disposed by GC? My object (call it A) write some variables in a global array-object, so when the object will be garbaged its own variable will stay in the global array-object, taking up memory. ps. i have numerous objects A and i prefer to not call "manually" a method to free my glo...

Static Semaphore passed as member to Thread class instance = bug?

There are a few windows service projects in our codebase that follow this model, and I just want to make sure it's not a bug. In this model, there is at least one static "timer" class, managed by a System.Timers.Timer, that retrieves batches of data to process from the database. A Semaphore is initialized as a static member. After re...

parent child relation in composite object ?

I have a composite object (tree) with parent-child relationships.The tree can be upto n levels (say for e.g 10-12 levels) Now suppose i have to remove an object at level 6 in the hierarchy.If i point its reference to null (while leaving the child object untouched) in Java then what happens to the child objects under it (do they become a...

Limiting the size of the managed heap in a C# application

Can I configure my C# application to limit its memory consumption to, say, 200MB? IOW, I don't want to wait for the automatic GC (which seems to allow the heap to grow much more than actually needed by this application). I know that in Java there's a command line switch you can pass to the JVM that achieves this.. is there an equivalent...

Debugging Ruby's garbage collection

I'm having problems with a long-lived background ruby process on our server, which isn't cleaning up Tempfiles. I'm using hijack to inject into the process & inspect things, using, for example, ObjectSpace.each_object(ActiveRecord::Base){|o| puts o} - turns out that the Tempfiles in question are being referenced by an instance of one ...

Manually garbage collection in Python

Is there any way to manually remove an object which the garbage collection refuses to get rid of even when I call gc.collect()? Working in Python 3.0 ...

LRU LinkedHashMap that limits size based on available memory

I want to create a LinkedHashMap which will limit its size based on available memory (ie. when freeMemory + (maxMemory - allocatedMemory) gets below a certain threshold). This will be used as a form of cache, probably using "least recently used" as a caching strategy. My concern though is that allocatedMemory also includes (I assume) u...

Using Image.FromFile does not release handle on a file

Hello, I'm doing a join of multiple multi-image tiff files to a single multi-image tiff file and have a problem with deleting the source tiff files, because the Image class continues to hold the handle on them. I'm reading a tiff image through Image.FromFile: Bitmap resultTiff = (Bitmap) Image.FromFile(strImageFile); After which I r...

Some Async Socket Code - Help with Garbage Collection?

Hi all, I think this question is really about my understanding of Garbage collection and variable references. But I will go ahead and throw out some code for you to look at. // Please note do not use this code for async sockets, just to highlight my question // SocketTransport // This is a simple wrapper class that is used as the 'st...

Methods and garbage collection

I encountered this question in an interview: Is an object created inside of a method eligible for garbage collection after the method is finished? Is yes the correct answer? ...

vector and garbage collector

I'm running a java program that uses many vectors. I'm afraid my use of them is causing the garbage collector not to work. I have many threads that do: vec.addAll(<collection>); and other threads that do: vec.remove(0); I have printouts that show the vector is empty from time to time but I was wondering if the memory is actually f...

Java instance variable visibility (ThreadLocal)

In the class ReentrantReadWriteLock is the following curious comment: transient ThreadLocalHoldCounter readHolds; Sync() { readHolds = new ThreadLocalHoldCounter(); setState(getState()); // ensures visibility of readHolds } what does it mean by "ensures visibility"? The reason I ask is that I have a situation where it looks a...

Java: Garbage Collection

I'm having an out of memory error. I have a large range of inputs (2^40), that is too large to hold at once. Each input is a String[]. Instead, I thought I'd run my test program on each input, write the results to a file, then discard the input. The length of the longest input is 42, so that isn't an error causing the overflow. I don't...

Garbage Collector in Real-Time System

I'm new to C#/Java and plan to prototype it for soft real-time system. If I wrote C#/Java app just like how I do in C++ in terms of memory management, that is, I explicitly "delete" the objects that I no longer use, then would the app still be affected by garbage collector? If so, how does it affect my app? Sorry if this sounds like an...

sed regex to non-greedy replace?

I am aware of another question that is quite similar, but for some reason I'm still having problems. I have a GC log that I'm trying to trim out the Tenured section enclosed in []. 63.544: [GC 63.544: [DefNew: 575K->63K(576K), 0.0017902 secs]63.546: [Tenured: 1416K->1065K(1536K), 0.0492621 secs] 1922K->1065K(2112K), 0.0513331 secs] I...

doubts regarding Memory management in .net

I'm ready about Memory management in C# from the book "Professional C#" The presence of the garbage collector means that you will usually not worry about objects that you no longer need; you will simply allow all references to those objects to go out of scope and allow the garbage collector to free memory as required. How...