garbage-collection

How to use Minimal GC in VC++ 2013? [duplicate]

拟墨画扇 提交于 2021-01-27 19:52:18
问题 This question already has an answer here : Garbage Collection in C++11 (1 answer) Closed 7 years ago . According to here, VC++ 2013 supports Minimal GC. Could you guys give me some examples to illustrate its usage? In other words, with VC++ 2013, how to use GC? The code example I want might look like this: auto p = gcnew int; Are there any? 回答1: You may be disappointed about what Minimal GC in C++11: It doesn't do garbage collection! The minimal garbage collection support in C++11 consists of

Why is garbage collection necessary?

浪尽此生 提交于 2021-01-27 19:40:51
问题 Suppose that an object on the heap goes out of scope. Why can't the program free the memory right after the scope ends? Or, if we have a pointer to an object that is replaced by the address to a new object, why can't the program deallocate the old one before assigning the new one? I'm guessing that it's faster not to free it immediately and instead have the freeing be done asynchronously at a later point in time, but I'm not really sure. 回答1: Why is garbage collection necessary? It is not

How to dispose a tabbed pane component completely from a JTabbedPane

纵然是瞬间 提交于 2021-01-27 19:08:01
问题 I have added a few tabs to a JTabbedPane. Each tab contains a JPanel. I now remove the tab by calling JTabbedPane.remove([tab index]). This removes the tab and everything is fine, except that when I profile the app, the JPanel added to the JTabbedPane does not get 'disposed' off and the reference is still present in the heap. After few 100 operations of adding the tab and closing it, the app goes Out of Memory. I analysed the heap dump using Eclipse MAT and I clicked on the Immediate

Installing libgc on OSX (Boehm's Garbage Collector)

老子叫甜甜 提交于 2021-01-27 18:40:22
问题 I've started by using reference counting in my library I'm making. It's a pretty decent solution and the increments and decrements don't waste many resources as some people wrongly seem to think. Also the slight extra memory for reference counts is negligible. But apparently tracing garbage collection is so good that it is better than using malloc/free. I'm not sure if this is true so I'd like to try it out (Back-end optimisations by freeing multiple objects at once?). Also GC would make my

What triggers garbage collection [duplicate]

↘锁芯ラ 提交于 2021-01-27 18:27:40
问题 This question already has answers here : What triggers a full garbage collection in Java? (2 answers) Closed 7 years ago . I know what all gets garbage collected. But what exactly tells JRE that it is time for garbage collection? Is it like some event or time interval? 回答1: HotSpot's garbage collection has grown into an exceedingly complex business, which even its creators struggle to understand in full detail. Therefore you can't be given a simple answer; some triggers are: occupation of

How garbage collection decides generation for variable

↘锁芯ラ 提交于 2021-01-27 18:05:36
问题 I know GC has 3 (0, 1, 2) generations but I'm wondering how GC decides the generation for a variable? I thought all variables go into generation 0 and after some time move to generations 1 and 2. Is it size matter for GC to decide the generation? Program1: private static void Main(string[] args) { int a = 0; string name = "Test"; var byteArray = new byte[10]; byteArray[4] = 4; Console.WriteLine($"Generation of array {GC.GetGeneration(byteArray)}"); Console.WriteLine($"Generation of local int

JAVA GC Major GC vs Minor GC

空扰寡人 提交于 2021-01-27 13:45:12
问题 In our latency sensitive app we have caching data (which resides in TG) and short lived object which die out in the YG. I have seen there is significant difference in the minor GC time and Major GC time. I suspected that it is related to relatively larger size of TG. Could anyone explain how the GC time correlates with the TG size . Minor GC is quite frequent and fast. 回答1: Objects which survive minor collection in YG gets moved to TG/Old generation to free up space in YG. Size of YG is kept

Java GC Promotion Failures

↘锁芯ラ 提交于 2021-01-27 13:04:53
问题 I have a 16G Heap size, with Young Gen = 4G and Old Gen = 12G on Java 6u43. I saw the following promotion failure. Whats interesting is right before the failure happened, the old gen size dropped from 12G to 9G, and young gen dropped from 3.4G to 0.3. But still promotion failed. My CMSIntitiatingOccupancyFraction = 75% and CMSInitiatingOccupancyOnly =true. Any help will be appreciated 2014-04-15T06:11:37.275-0400: 200306.377: [GC 200306.377: [ParNew Desired survivor size 214728704 bytes, new

Force garbage collection of JavaScriptCore virtual machine on iOS

こ雲淡風輕ζ 提交于 2021-01-27 05:24:49
问题 Is there any way to force iOS (or Mac OS) JavaScriptCore VM garbage collector to run? I need it only to test for memory leaks, so private API would be fine. 回答1: Use following function from JSBase.h: /*! @function JSGarbageCollect @abstract Performs a JavaScript garbage collection. @param ctx The execution context to use. @discussion JavaScript values that are on the machine stack, in a register, protected by JSValueProtect, set as the global object of an execution context, or reachable from

Force garbage collection of JavaScriptCore virtual machine on iOS

强颜欢笑 提交于 2021-01-27 05:24:38
问题 Is there any way to force iOS (or Mac OS) JavaScriptCore VM garbage collector to run? I need it only to test for memory leaks, so private API would be fine. 回答1: Use following function from JSBase.h: /*! @function JSGarbageCollect @abstract Performs a JavaScript garbage collection. @param ctx The execution context to use. @discussion JavaScript values that are on the machine stack, in a register, protected by JSValueProtect, set as the global object of an execution context, or reachable from