garbage-collection

CMS garbage collector - when does it run?

半世苍凉 提交于 2019-12-28 13:50:10
问题 I am confused about two parameters that may control when the CMS collector kicks in: MaxHeapFreeRatio (70% by default) CMSInitiatingOccupancyFraction (over 90% by default) What does each of those parameters mean, exactly? When does the collector start (the marking phase), and collect (the sweeping phase)? 回答1: CMSInitiatingOccupancyFraction decides when the CMS kicks in (in order for this option to be effective you must also set -XX:+UseCMSInitiatingOccupancyOnly ). MaxHeapFreeRatio is an

CMS garbage collector - when does it run?

南楼画角 提交于 2019-12-28 13:50:09
问题 I am confused about two parameters that may control when the CMS collector kicks in: MaxHeapFreeRatio (70% by default) CMSInitiatingOccupancyFraction (over 90% by default) What does each of those parameters mean, exactly? When does the collector start (the marking phase), and collect (the sweeping phase)? 回答1: CMSInitiatingOccupancyFraction decides when the CMS kicks in (in order for this option to be effective you must also set -XX:+UseCMSInitiatingOccupancyOnly ). MaxHeapFreeRatio is an

Garbage Collection and Finalizers: Finer Points

泪湿孤枕 提交于 2019-12-28 12:08:14
问题 In answering another question* on SO, and the subsequent comment discussion, I ran into a wall on a point that I'm not clear on. Correct me on any point where I'm astray... When the Garbage Collector collects an object, it calls that object's finalizer, on a separate thread (unless the finalizer has been suppressed, e.g. through a Dispose() method). While collecting, the GC suspends all threads except the thread that triggered the collection (background collection aside). What isn't clear:

free() on stack memory

泄露秘密 提交于 2019-12-28 06:46:33
问题 I'm supporting some c code on Solaris, and I've seen something weird at least I think it is: char new_login[64]; ... strcpy(new_login, (char *)login); ... free(new_login); My understanding is that since the variable is a local array the memory comes from the stack and does not need to be freed, and moreover since no malloc/calloc/realloc was used the behaviour is undefined. This is a real-time system so I think it is a waste of cycles. Am I missing something obvious? 回答1: You can only free()

Is there a way to retrieve a C# app's current memory usage?

核能气质少年 提交于 2019-12-28 06:17:52
问题 I am automating some profiling tasks and want to log heap space and generation sizes real-time. The profiling API seems awfully complicated for what I need, and it seems to listen in on individual allocations and collections, which isn't that important to me. Profiling tools are a great help of course, but I was looking for a more flexible, programmable interface. 回答1: The term 'current memory usage' is a little loosely defined. Do you mean the working set? Whatever it means, you can use

requestAnimationFrame garbage collection

百般思念 提交于 2019-12-28 05:09:29
问题 I'm profiling the following code's memory usage using the Timeline in Chrome Dev Tools v27. <!DOCTYPE html> <html> <head> <meta http-equiv='content-type' content='text/html; charset=UTF-8' /> <title>RAF</title> </head> <body> <script type='text/javascript' charset='utf-8'> var frame = function() { window.webkitRequestAnimationFrame(frame); }; window.webkitRequestAnimationFrame(frame); </script> </body> </html> Notice it's simple. But eventually I see the a tooth pattern appear that indicates

Very High Memory Usage in .NET 4.0

喜你入骨 提交于 2019-12-28 05:02:32
问题 I have a C# Windows Service that I recently moved from .NET 3.5 to .NET 4.0. No other code changes were made. When running on 3.5, memory utilzation for a given work load was roughly 1.5 GB of memory and throughput was 20 X per second. (The X doesn't matter in the context of this question.) The exact same service running on 4.0 uses between 3GB and 5GB+ of memory, and gets less than 4 X per second. In fact, the service will typically end up stalling out as memory usage continue to climb until

Timer, event and garbage collection : am I missing something?

穿精又带淫゛_ 提交于 2019-12-28 02:09:10
问题 Consider the following code : class TestTimerGC : Form { public TestTimerGC() { Button btnGC = new Button(); btnGC.Text = "GC"; btnGC.Click += (sender, e) => GC.Collect(); this.Controls.Add(btnGC); System.Windows.Forms.Timer tmr = new System.Windows.Forms.Timer(); tmr.Interval = 1000; tmr.Tick += (sender, e) => this.Text = DateTime.Now.ToString(); tmr.Start(); } } If I'm not mistaken, after the tmr variable goes out of scope, the Timer isn't referenced anywhere, so it should be eligible for

Garbage collection of String literals

吃可爱长大的小学妹 提交于 2019-12-27 09:53:37
问题 I am reading about Garbage collection and i am getting confusing search results when i search for String literal garbage collections. I need clarification on following points: If a string is defined as literal at compile time [e.g: String str = "java" ] then will it be garbage collected? If use intern method [e.g: String str = new String("java").intern() ] then will it be garbage collected? Also will it be treated differently from String literal in point 1. Some places it is mentioned that

Garbage collection of String literals

巧了我就是萌 提交于 2019-12-27 09:53:24
问题 I am reading about Garbage collection and i am getting confusing search results when i search for String literal garbage collections. I need clarification on following points: If a string is defined as literal at compile time [e.g: String str = "java" ] then will it be garbage collected? If use intern method [e.g: String str = new String("java").intern() ] then will it be garbage collected? Also will it be treated differently from String literal in point 1. Some places it is mentioned that