garbage-collection

What exactly is garbage collection and how do you do it in ActionScript 3.0?

I've been programming in ActionScript for about 6 years now but never heard of the term 'garbage collection' until AS3 came out. Why do we have to worry about it now, and never before? And what, precisely, is it? From what I've read/heard, it has something to do with memory management/leaks, etc. -- and even that I don't understand much ...

Python garbage collection

I have created some python code which creates an object in a loop, and in every iteration overwrites this object with a new one of the same type. This is done 10.000 times, and Python takes up 7mb of memory every second until my 3gb RAM is used. Does anyone know of a way to remove the objects from memory? ...

Will .Net Garbage Collect an object that's not referenced, but has a thread that's doing work?

I have the following code (cut down for readability): Main Class: public StartProcess() { Thinker th = new Thinker(); th.DoneThinking += new Thinker.ProcessingFinished(ThinkerFinished); th.StartThinking(); } void ThinkerFinished() { Console.WriteLine("Thinker finished"); } Thinker Class: public class Thinker { p...

How to get unused memory back from the large object heap LOH from multiple managed apps?

While talking to a colleague about a particular group of apps using up nearly 1.5G memory on startup... he pointed me to a very good link on .NET production debugging The part that has me puzzled is ... For example, if you allocate 1 MB of memory to a single block, the large object heap expands to 1 MB in size. When you free t...

Unloading objects for the garbage collector in AS3

I've created an object called loginInterface in flex builder. When this object is initialized it loads the login interface, creating buttons, input boxes and so on. I created a method for this object called unload. I also have a method which returns whether the interface has been loaded yet. Now, I want to unload the object so that the ...

What is the standard parallel GC called in JVM crash dumps?

When the JVM runs with the -XX:+UseParNewGC we are getting an occasional access violation. When we look at the dump file, we see Heap par new generation total 14784K, used 13689K [0x02bd0000, 0x03bd0000, 0x06950000) eden space 13184K, 100% used [0x02bd0000, 0x038b0000, 0x038b0000) from space 1600K, 31% used [0x03a40000, 0x03abe6...

can a GC be implemented with C++ raw pointers ?

I was wondering how a Garbage Collector can be implemented with C++ full power of pointers arithmetic. Also, In languages like Java, I can not assign literal addresses to references. In C++ it is very flexible. I believe that C# has both, but again, the unsafe pointer in C# is the responsibility of the programmer. EITD :: guys, I am as...

Does a FileStream object (.NETCF, C#) created using handle returned from Win32 API CreateFile (C++, P/Invoke) prone to .NET Garbage Collection

UPDATED QUESTION Since the ctor is not supported by .NETCF (public FileStream(IntPtr handle, FileAccess access). Could you please suggest other ways of sharing large file in memory between managed and unmanaged code on a limited resource (RAM) platform. Basically I want to map the file in the upper region of 2GB user space (Win CE 5.0) ...

How to use garbage collection to delete files ?

Hi I am using a lot of temporary files in java and my problem is that they do not get deleted. Without having to implement my own handling of temporary file management (not hard I grant you but I am lazy plus with so many things to do If I can save reinventing the wheel for this all the better) is there a way to ensure the temp files on...

monitoring java memory usage

We have a j2ee application running on Jboss and we want to monitor its memory usage. Currently we use the following code System.gc(); long usedMB = (rt.totalMemory() - rt.freeMemory()) / 1024 / 1024; logger.information(this, "memory usage" + usedMB); This code works fine. That means it shows memory curve which corresponds...

Does iPhone OS 3.0 have a real garbage collector?

If not, are there any plans to add Garbage Collection to the iPhone? Related question: This question from January (pre OS 3.0) says the iPhone had no GC at the time. Thanks! ...

Removing all references to an object removes event listeners inside that object?

When I have an object, removing all references to it is enough to sign it up for the garbage collector, atleast that's what I heard. Eg.: removeChild(object); object = null; I'm still a bit confused though, because does this mean that the event listeners made inside this object's instance are also automatically removed? Or is there an...

Trying to track down a memory leak / garbage-collection problem in Java.

This is a problem I have been trying to track down for a couple months now. I have a java app running in that processes xml feeds and stores the result in a database. This has been giving intermittent resource problems that are very difficult to track down. Background: On the production box (where the problem is most noticeable), i do n...

gc question: array of 10 ints a single object or 10 objects?

If i have an array say - int[] a = new int[10]; does the Java GC when doing its collection see that as 10 objects or a single object? Update: so according to the given answers, looking at it from a GC perspective isnt it more efficient that instead of List l; for(i =0;i<1000;i++) l.add(new MyObj(343,"asdfasfd")); we should d...

Do I need to remove event subscriptions from objects before they are orphaned?

If my software has two object instances, one of which is subscribed to the events of the other. Do I need to unsubscribe them from one another before they are orphaned for them to be cleaned up by the garbage collector? Or is there any other reason why I should clear the event relationships? What if the subscribed to object is orphaned b...

Cocoa network streams and the garbage collector.

I'm writing a little network application in Cocoa, using objective-c 2.0. I have the garbage collector enabled in required mode (-fobjc-gc-only). When I run the code most of the time it works like a charm. But sometimes it just crashes without warning, and gdb launches. I'm as yet unable to get any useful info from GDB. The code is as fo...

What exactly takes place behind the scenes when you call System.gc()?

Calling System.gc() requests that garbage collection takes place, and isn't guaranteed. The part about it not being guaranteed is interesting to me: can someone explain the exact process that takes place when you make this call? ...

Weak events in .NET?

If object A listens to an event from object B, object B will keep object A alive. Is there a standard implementation of weak events that would prevent this? I know WPF has some mechanism but I am looking for something not tied to WPF. I am guessing the solution should use weak references somewhere. ...

.NET Garbage Collector Basics

I apologize if the answer to this question is trivial. But I still cannot figure out this by myself. How does the garbage collector in .NET identify what objects on the heap are garbage and what objects are not? Lets say a .NET application is running and at a certain point of time garbage collection occurs(lets leave out the generatio...

How does the operating system know how much memory my app is using? (And why doesn't it do garbage collection?)

When my task manager (top, ps, taskmgr.exe, or Finder) says that a process is using XXX KB of memory, what exactly is it counting, and how does it get updated? In terms of memory allocation, does an application written in C++ "appear" different to an operating system from an application that runs as a virtual machine (managed code like ...