garbage-collection

Object Not Garbage Collected

Hello All, I have a third party component I'm using and I'm seeing some issues with resources not being released. The component causes windows to create a handle to a UDP socket ("\Device\Udp" as well as "\Device\Afd"). If I allow the program to execute and dereference the third party object, I assumed that like all .NET objects I've ...

garbage collection for inner objects

class Stage { Actor act1 = new Actor(); Actor act2 = new Actor(); Actor act3 = new Actor(); } Stage stg = new Stage(); how will garbage collection behave in java this scenario? stg = null; will the three objects created act1,act2 and act3 also get garbage collected? ...

Force garbage collection of arrays, C#

I have a problem where a couple 3 dimensional arrays allocate a huge amount of memory and the program sometimes needs to replace them with bigger/smaller ones and throws an OutOfMemoryException. Example: there are 5 allocated 96MB arrays (200x200x200, 12 bytes of data in each entry) and the program needs to replace them with 210x210x210...

Why does Django's signal handling use weak references for callbacks by default?

The Django docs say this on the subject: Note also that Django stores signal handlers as weak references by default, so if your handler is a local function, it may be garbage collected. To prevent this, pass weak=False when you call the signal’s connect(). I haven't been able to find any justification for why this is the ...

I thought the managed heap grew dynamically?

If I'm understanding this correctly about garbage collection in .NET CLR, then GC occurs when space for a reference types allocation is needed but there is no more room on the managed heap. So does the managed heap have a limit as to how big it will get? Thanks. ...

Is there a way to include a VM parameter inside a .jar?

I have a game implemented in Java that was having a problem when running too much code from scripts: depending on the script language, the game could have these "hiccups" where the game would freeze for a couple frames every now and then, making the game "jerky" at times. After some research, I discovered that was happening when the Gar...

How to avoid reference count underflow in _NSCFURLProtocolBridge in custom NSURLProtocol in GC environment

The basics are I have a custom NSURLProtocol. In startLoading, [self client] is of type: <_NSCFURLProtocolBridge> {NSURLProtocol, CFURLProtocol} The problem is running this in a garbage-collected environment. Because I'm writing a screensaver, I'm forced to make it garbage-collected. However, the _NSCFURLProtocolBridge protocol see...

Why is this being garbage collected

My developers and I are having an issue with objects being garbage collected in our application when we don't want them to be. We are using Java with Weblogic 10g3. We are programming a singleton pattern to handle all of our JMS connections. There are two classes involved: public class JMSObject { ... private MessageProducer _produce...

Python object has no referrers but still accessible via a weakref?

Should it be possible for gc.get_referrers(obj) to return an empty list for an object, but the object still be accessible through a weak reference? If so how would I start trying to identify the cause for this object not being garbage collected? Edit: I'm not sure exactly how a code sample would help in this case - there's obviously a ...

Java garbage collection of run-time generated code

I'm looking at the possibility of generating Java byte code at run time (hopefully directly in memory rather than via class files, though I imagine that won't make a difference to my question). I understand this can be done, the question is, does the garbage collector sweep up no-longer-used code? I remember some years ago seeing it cla...

Should a programmer really care about how many and/or how often objects are created in .NET?

This question has been puzzling me for a long time now. I come from a heavy and long C++ background, and since I started programming in C# and dealing with garbage collection I always had the feeling that such 'magic' would come at a cost. I recently started working in a big MMO project written in Java (server side). My main task is to...

Is GCLatencyMode.LowLatency a good choice?

I have a C# windows service acting as a server, the service holds some large (>8Gb) data structures in memory and exposes search methods to clients via remoting. The avg search operation is executed in <200ms and the service handles up to 20 request/sec. I'm noticing some serious performance degradation (>6000ms) on a regular basis fo...

Does a lambda create a new instance everytime it is invoked?

I'm curious to know whether a Lambda (when used as delegate) will create a new instance every time it is invoked, or whether the compiler will figure out a way to instantiate the delegate only once and pass in that instance. More specifically, I'm wanting to create an API for an XNA game that I can use a lambda to pass in a custom call ...

Can I detect when the Garbage collector works?

Am working on a swing app. I will experiance slowness after continuous half an hour of use. can it because of GC running? How can i find when the garbage collector runs through any jdk 1.5 commandline option? Thanks ...

Managed events and native consumers

I recently came across this extremely useful SO question that explains how a native class can be the consumer of managed events. I have managed to successfully implement this is our codebase. But we're paranoid about unsubscribing from events we have subscribed to, especailly when there are statics involved as we've been burnt by stati...

C#: Notification before WeakReference is collected?

Hi, In C#/.NET, is there any way to get a notification before the object pointed to by a weak reference is destructed? Basically, I want to allow an object to be collected, but do something right before the object is destroyed, without modifying code to add destructors (since I won't know exactly what types of objects will be sued with ...

Getting list of objects referring to an Object

Given a Java Object, how can I get a list of Objects that referring to it? There must be extension mechanisms in the GC for doing this kind of thing, just can't seem to find them. ...

When to Garbage Collect

I have a piece of code that load a very big image in memory. So it seemed like a reasonable thing to call System.gc(); before loading the image. From what I can tell it works with no issues. Yesterday i decided to use a pretty useful piece of software called FindBugs that scans your code and reports back issues that might cause bugs...

How can I estimate amount of memory left with calling System.gc()?

I have some data processing code which uses the following recipe: Read in as much data as will fit in memory (call this a 'chunk') Perform processing on the chunk Write out processed chunk to disk Repeat ... Merge all the processed chunks to get the final answer. This last stage is most efficient when there are as few chunks as possi...

GC.AddMemoryPressure question

I've read about it on msdn and on CLR via c#. My main question about it is the following: let's imagine we have a 2Mb unmanaged HBITMAP allocated and a 8 bytes managed bitmap pointing to it. What's the point of telling the GC about it with AddMemoryPressure if it is never going to be able to make anything about the object, as it is allo...