garbage-collection

Portable equivalent to gcc's __attribute__(cleanup)

Recently I came across a gcc extension that I have found rather useful: __attribute__(cleanup) Basically, this allows you to assign a cleanup call to a local variable at the time it exits scope. For instance, given the following section of code, all memory must be maintained and handled explicitly in any and all cases within the call to...

Will my object always "be there"?

If I have an object stored in memory, and I walk away from my application for an hour, will the object still be there when I get back? In other words, will the .NET garbage collector throw my object away because it hasn't been used for awhile? ...

Can the performance timer "% Time in GC" be wrong?

We found that, since today, the "% Time in GC" (percent time in Garbage Collector) performance timer, steadily stood on 100% with only occasionally a bit lower. Even when at night no visitors were online. Then I placed App_Offline.htm in the root. Usually this brings down all ASP.NET activity. But for some odd reason, the "% Time in GC"...

Understanding Java's GC logs

I turned on verbose GC options on my JDK, and now I'm seeing lines such as 25.598: [CMS-concurrent-sweep-start] 25.622: [CMS-concurrent-sweep: 0.023/0.024 secs] [Times: user=0.02 sys=0.00, real=0.03 secs] 25.623: [CMS-concurrent-reset-start] 25.629: [CMS-concurrent-reset: 0.007/0.007 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] ...

"abort preclean due to time" in Concurrent Mark & Sweep

I'm getting "abort preclean due to time" when running Concurrent Mark & Sweep in Java 6. What does it mean? Is the GC really halting in the middle before it did any real work? ...

Adding Timestamp to Java's GC messages in Tomcat 6

I turned on Java's GC log options -XX:+PrintGC -XX:+PrintGCTimeStamps -XX:+PrintGCDetails Which print out these messages to standard output (catalina.out): 314.884: [CMS-concurrent-mark-start] 315.014: [CMS-concurrent-mark: 0.129/0.129 secs] [Times: user=0.14 sys=0.00, real=0.13 secs] 315.014: [CMS-concurrent-preclean-start] 315.0...

Analyze GC logs for Sun Hotspots, JVM 6

I'm trying to analyze GC behaviour for our application (running in Tomcat, under Sun's Hotspots, JVM 1.6). So far I've: Instructed the JVM to emit GC logs to a separate file using: -Xloggc:gc.log -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCApplicationConcurrentTime -XX:+PrintGC -XX:+PrintGCTimeStamps -XX:+PrintGCDetails ...

Change in GC behaviour after move from Java5 to 6

We've recently migrated our systems from Sun Java 5 to Java6 server VM (specifically, 1.6.0_16 on Linux 32 bit). We've noticed that the garbage collection behaviour has changed in such a way as to trigger our heap-warning monitoring system. The heap usage graphs indicate a much "spikier" memory usage profile than we saw with Java5, wit...

Java Outputstream behavior when multiple outputstream objects are wrapped

Hi, I have a code that does compression, encryption and checksum on a File Outputstream. Following is the code- private void start() { OutputStream os = null; try { os = new FileOutputStream("/some/file"); os = wrapAllRequiredTransforms(os); //Write to os } finally { os.close(); } } private wrap...

alloca and ObjectiveC Garbage Collector

In an objective C project with GC enabled, I am allocating an array of variable size on the stack like this: MaValue *myStack = alloca((sizeof(id) * someLength)); (The reason why I want to do this is not important:) Then, within a loop, I push and pop stuff on/from myStack. Some of the things I push onto the stack are new objects that...

Assigning "null" to objects in every application after their use

Do you always assign null to an object after its scope has been reached? Or do you rely on the JVM for garbage collection? Do you do it for all sort of applications regardless of their length? If so, is it always a good practice? ...

Why are file handles such an expensive resource?

In holy wars about whether garbage collection is a good thing, people often point out that it doesn't handle things like freeing file handles. Putting this logic in a finalizer is considered a bad thing because the resource then gets freed non-deterministically. However, it seems like an easy solution would be for the OS to just make s...

Why don't managed languages offer the ability to manually delete objects?

Lets say you want to write a high performance method which processes a large data set. Why shouldn't developers have the ability to turn on manual memory management instead of being forced to move to C or C++? void Process() { unmanaged { Byte[] buffer; while (true) { buffer = new Byte[10240...

.NET Garbage Collection and Native Threads

It’s fairly well documented that when .NET's automatic garbage collector runs, it will temporarily pause all running managed threads associated with the application domain. What I haven't been able to discover are details on what happens to native threads created by the application when garbage collection occurs (ie. using _beginthreadex...

Definition of Java's CMS GC log lines?

Examining a Java runtime with CMS (Concurrent-Mark-Sweep) GC enabled, what is the definition of the CMS space in the logs below? Shall I assume it is the tenured space? I see the following lines of a minor-major-minor GC event 23.481: [GC 23.481: [DefNew: 1051K->128K(1152K), 0.0029912 secs] 11925K->11027K(13600K), 0.0031697 secs] [Tim...

Is it possible to change the priority of garbage Collector thread?

Java garbage collector runs with priority 1, due to which it is not guaranteed that System.gc() will actually execute if called. Is there any way to change its priority? This shall enable me to run if I want. ...

What GC parameters is a JVM running with?

I'm still investigating issues I have with GC tuning (see prior question), which involves lots of reading and experimentation. Sun Java5+ JVMs attempt to automatically select the optimal GC strategy and parameters based on their environment, which is great, but I can't figure out how to query the running JVM to find out what those param...

Why does AppDomain.Unload() error in finalizer?

Here's some sample code: using System; namespace UnloadFromFinalizer { class Program { static void Main(string[] args) { Program p = new Program(); } AppDomain domain; Program() { this.domain = AppDomain.CreateDomain("MyDomain"); } ~Program...

Garbage Collector

i want to know the internal architecture and function of the garbage collector in dotnet in detail.. can anybody help me. ...

Garbage Collection in Java and Circular References

From my understanding, garbage collection in java cleans up some object iff nothing else is 'pointing' to that object. My question is, what happens if we have something like: class Node{ public object value; public Node next; public Node(object o, Node n) { value = 0; next = n;} } //...some code { Node a = new Node("a", n...