garbage-collection

JVM throws OutOfMemory during gc though there are plenty memory left...

I have my java application configured to use 5G memory. I got an OutOfMemory out of blue. I inspected the gc log and found plenty of memory left: young generation occupies 4% allocated space, tenure generation occupancy is 5% and perm generation is 43%. I am puzzled why JVM throws an OutOfMemory at the gc time. Does anyone know why this ...

[C#] How to implement my own byte array creation and disposal

BACKGROUND: In running my app through a profiler, it looks like the hotspots are all involved in allocating a large number of temporary new byte[] arrays. In one run under CLR Profiler, a few short (3-5 seconds worth of CPU time outside the profiler) produced over a gigabyte of garbage, the majority of it byte[] allocation, and this t...

C# - Is it Possible to Iterate GC Heap ?

I'm not sure whether the following questions are valid.To educate myself i am just asking. ( 1 ) Can I programmatically iterate the GC Heap of all generations ? ( 2 ) Is it possible to watch how does the GC operate on my assembly by launching a thread ? ...

GC Not Running Often Enough on IIS 7 Application - Windows Server 2008

I have a web application that is eventually running out of memory when it runs on IIS 7 Windows Server 2008. When I attempt to run a memory profiler against the application to determine the leak, it is not reproducible on my development workstation...Windows Vista. The GC collection cycles are not consistent between the server and the ...

Forcing garbage collection to run in R with the gc() command

Periodically I program sloppily. Ok, I program sloppily all the time, but sometimes that catches up with me in the form of out of memory errors. I start exercising a little discipline in deleting objects with the rm() command and things get better. I see mixed messages online about whether I should explicitly call gc() after deleting lar...

GC.Collect on only generation 2 & large object heap

In my application there is a specific time when a number of large objects are all released at once. At that time I would like to do a garbage collection on specifically the large object heap (LOH). I'm aware that you cannot do that, you must call GC.Collect(2) because the GC is only invoked on the LOH when it is doing a generation 2 co...

How can I get reference count for a managed object?

.NET profilers can show reference count to managed objects. How do they count them? ...

Is it possible to prevent garbage collection at the time it was called?

I want to implement some reusable object pool. Also I don't want to have API that puts the object back to pool when it is not needed. I want to use garbage collector to inform me that it is going to remove the object because it has no references, so that I could stop the object from being garbage collected and put it back to the pool. ...

Find references to the object in runtime

I have an object, which lives forever. I am deleteing all references I can see, to it after using it, but it still not collected. Its life cycle is pretty sophisticated so I can't be sure that all references been cleared. if ( container.Controls.Count > 0 ) { var controls = new Control[ container.Controls.Count ]; container.Con...

How to pause Garbage Collection in .NET?

I'm running some performance tests on some .NET code that processes lots of data. I want some tests that ensure the garbage collector isn't influencing my results. How do I temporarily pause the garbage collector? ...

what happens to a python object when you throw an exception from it

My class contains a socket that connects to a server. Some of the methods of the class can throw an exception. The script I'm running contains an outer loop that catches the exception, logs an error, and creates a new class instance that tries to reconnect to the server. Problem is that the server only handles one connection at a time (...

for line in open(filename)

I frequently see python code similar to for line in open(filename): do_something(line) When does filename get closed with this code? Would it be better to write with open(filename) as f: for line in f.readlines(): do_something(line) ...

C# - Are objects immediately destroyed when going out of scope?

Can I trust that an object is destroyed and its destructor is called immediately when it goes out of scope in C#? I figure it should since many common coding practices (e.g. transaction objects) rely on this behaviour, but I'm not very used to working with garbage collection and have little insight to how such languages usually behave. ...

Forcing Garbage Collection in Java?

Hello there, Please anyone can tell me if I can force garbage collection in java anyway? Even it was tricky to do. I know about System.gc(); and Runtime.gc(); but they don't force, they suggest to do GC, but actually no force occurs. Please I need that horribly. Best Regards, Tarek, ...

Why are weak pointers useful?

I've been reading up on garbage collection looking for features to include in my programming language and I came across "weak pointers". From here: Weak pointers are like pointers, except that references from weak pointers do not prevent garbage collection, and weak pointers must have their validity checked before they are...

Event subscription to a static instance. How to ensure GC.

Hi. I'm fixing a User control component using the .NET 1.1 framework. There are many instances of this user control referencing a singleton wrapping a COM resource. They subscribe to events from this resource. I suspect that the reason why we are having a degrading performance is because the singleton is maintaining a reference to t...

Guidance on optimising Python runtime for embedded systems with low system resources

My team is incorporating the Python 2.4.4 runtime into our project in order to leverage some externally developed functionality. Our platform has a 450Mhz SH4 application core and limited memory for use by the Python runtime and application. We have ported Python, but initial testing has highlighted the following hurdles: a) start-...

What's a good library to do computational geometry (like CGAL) in a garbage-collected language?

I need a library to handle computational geometry in a project, especially boolean operations, but just about every feature is useful. The best library I can find for this is CGAL, but this is the sort of project I would hesitate to make without garbage collection. What language/library pairs can you recommend? So far my best bet is i...

Do event handlers stop garbage collection if the hanlder is in a seperate assembly?

If I have a class declared in assembly A, and am listening to it in assembly B, will this prevent garbage collection. Its a common situation, such as the one where you are listening to a property of an object in the business model from the ui. i saw this question which talks about event listeners and garbage collection, but this questio...

Javascript memory management pitfalls ?

I know that Javascript has a garbage collector. Therefor, using delete remove only a reference to the object, and when there is no more reference to this object, it is deleted by the GC. Javascript is tricky, with the closures, the fuzzy name space and the prototype inheritance, it's not always obvious to know when to now or why. I am ...