garbage-collection

Does C# app exit automatically dispose managed resources?

故事扮演 提交于 2020-01-23 06:16:13
问题 I am fully aware that using statements are the way to handle IDisposables. Please do not repeat this advice in comments. When a C# .NET 4.5 (or higher) application closes, what happens to the IDisposables which were not properly disposed? I know some have a finalizer for disposing unmanaged resources. But let's say I have a console app, with a static Stream variable. Is it disposed when I close the console app? What about a HttpClient? And how do you know in which situations it does and in

ActionScript - Forced Garbage Collection Not Working In ADL?

荒凉一梦 提交于 2020-01-23 03:29:06
问题 when launching the following code in ADL, why does the square continue to rotate? var square:Sprite = new Sprite(); square.graphics.beginFill(0xFF0000); square.graphics.drawRect(-25, -25, 50, 50); square.x = square.y = 100; addChild(square); addEventListener(Event.ENTER_FRAME, rotateSquare, false, 0, true); function rotateSquare(evt:Event):void { square.rotation += 2; } System.gc(); Update the following display object has a weak referenced ENTER_FRAME event listener. however, calling:

WeakReference Behavior When Object Is Finalized But Not Yet Garbage Collected

穿精又带淫゛_ 提交于 2020-01-22 20:50:10
问题 Here's an academic question about object finalization and collection in C#/.NET. Background reading is section 3.9 of the C# language spec, Automatic Memory Management. When there are no explicit references to an object, it may become garbage collected. It becomes "eligible for destruction". At some point in the future (e.g. if you force garbage collection), the object's destructor will be run. In the destructor, if you save a reference to the object, the object will be finalized, but will

Garbage collection and cgo

孤人 提交于 2020-01-22 09:44:07
问题 Is it possible to make the garbage collector in Go handle and release memory allocated through C code? I apologize, I haven't used C and cgo before so my examples may need some clarification. Lets say you've got some C library that you'd like to use and this library allocates some memory that needs to be freed manually. What I'd like to do is something like this: package stuff /* #include <stuff.h> */ import "C" type Stuff C.Stuff func NewStuff() *Stuff { stuff := Stuff(C.NewStuff()) //

Scalability of the .NET 4 garbage collector

大兔子大兔子 提交于 2020-01-22 05:48:24
问题 I recently benchmarked the .NET 4 garbage collector, allocating intensively from several threads. When the allocated values were recorded in an array, I observed no scalability just as I had expected (because the system contends for synchronized access to a shared old generation). However, when the allocated values were immediately discarded, I was horrified to observe no scalability then either! I had expected the temporary case to scale almost linearly because each thread should simply wipe

C++/CLI: preventing garbage collection on managed wrapper of unmanaged resource

只谈情不闲聊 提交于 2020-01-21 06:29:05
问题 I have a C++ unmanaged class NativeDog that needs to be used from C#, so I've create a wrapper class ManagedDog . // unmanaged C++ class class NativeDog { NativeDog(...); // constructor ~NativeDog(); // destructor ... } // C++/CLI wrapper class ref class ManagedDog { NativeDog* innerObject; // unmanaged, but private, won't be seen from C# ManagedDog(...) { innerObject = new NativeDog(...); ... } ~ManagedDog() // destructor (like Dispose() in C#) { // free unmanaged resources if (innerObject)

Could not allocate enough heap space to Java

半腔热情 提交于 2020-01-21 05:17:40
问题 We have an application which was running fine for one year. It is a web application, running under Tomcat 5.5 + JDK 1.5 under Microsoft Cluster on Windows Server 2003 Enterprise Edition Service Pack 2. The server has 11Gb of RAM (I know that it is useless!) with the following description "Physical Address Extension": I don't know what that means. The Tomcat service is configured with the following parameters: -Xmx1024m -Xms128m Since last week, the service doesn't want to start anymore and

Could not allocate enough heap space to Java

独自空忆成欢 提交于 2020-01-21 05:17:12
问题 We have an application which was running fine for one year. It is a web application, running under Tomcat 5.5 + JDK 1.5 under Microsoft Cluster on Windows Server 2003 Enterprise Edition Service Pack 2. The server has 11Gb of RAM (I know that it is useless!) with the following description "Physical Address Extension": I don't know what that means. The Tomcat service is configured with the following parameters: -Xmx1024m -Xms128m Since last week, the service doesn't want to start anymore and

What the frequency of the Garbage Collection in Java?

别等时光非礼了梦想. 提交于 2020-01-21 04:45:10
问题 Page 6 of the the document Memory Management in the Java HotSpot™ Virtual Machine contains the following paragraphs: Young generation collections occur relatively frequently and are efficient and fast because the young generation space is usually small and likely to contain a lot of objects that are no longer referenced. Objects that survive some number of young generation collections are eventually promoted, or tenured, to the old generation. See Figure 1. This generation is typically larger

where does a “static final” directly allocated into? young gen or old gen or perm gen?

99封情书 提交于 2020-01-21 03:45:06
问题 Is a "static final" directly allocated into young gen or old gen or perm gen? (I guess it will most likely land into old gen over the time I suppose.) If it is allocated in the perm gen then, will it be garbage collected when class unloading takes place in Perm Gen ? 回答1: Is a "static final" directly allocated into young gen or old gen or perm gen? An object referenced by a static final variable will be allocated according to the same rules as any other object. It is most likely to be