garbage-collection

Static methods vs instance methods in C#

我是研究僧i 提交于 2019-12-22 05:23:26
问题 For an application I am writing, I want to have extreme extensibility and extension methods seem to give me what I want, plus the ability to call them without an instance, which I need too. I remember reading that static methods are faster than instance methods but don't get the advantages of GC. Is this correct? It's highly unlikely I will change my design unless I find a superior alternative by design not speed. But still for extra information I wanna know the differences in speed, GC, etc.

Understanding gc.get_referrers

我与影子孤独终老i 提交于 2019-12-22 04:58:44
问题 I'm trying to track a memory leak in Python (2.7). I've found gc.get_referrers, but don't understand the output. After deleting dying_node (which should get rid of all references except for a list that I've created as part of my hunting), I have in my code: gc.collect() print "done dying: ", getrefcount(dying_node) #note, includes the reference from getrefcount referrers = gc.get_referrers(dying_node) print "referrers: " for referrer in referrers: print referrer which yields the output: >

Why does allocated size of permanent generation increase after executing perform GC?

不想你离开。 提交于 2019-12-22 04:51:04
问题 Following are the snapshots I took after executing perform GC from jvisualvm. and First image is Heap stats and 2nd one is perm gen stats. I am not able to understand when I did GC utilized heap size decreased(as expected) but the allocated size of permanent generation increased (though the utilized permgen size remained the same). What could be the possible explanation of such behavior? JVM arguments used -Xbootclasspath/p:../xyz.jar -Xbootclasspath/a:../abc.jar -Djava.endorsed.dirs=..

Will Java's garbage collector go ahead and take care of variables declared within loops?

只谈情不闲聊 提交于 2019-12-22 04:46:17
问题 If I have: for (int i; i != 100; i++) { ArrayList<String> myList = buildList(); //... more work here } Do I have to set myList to null at the end of my loop to get the GC to reclaim the memory it uses for myList? 回答1: The GC will automatically clean up any variables that are no longer in scope. A variable declared within a block, such as a for loop, will only be in scope within that block. Once the code has exited the block, the GC will remove it. This happens as soon as an iteration of the

Is using StringBuilder Remove method more memory efficient than creating a new StringBuilder in loop?

爱⌒轻易说出口 提交于 2019-12-22 04:32:27
问题 In C# which is more memory efficient: Option #1 or Option #2? public void TestStringBuilder() { //potentially a collection with several hundred items: string[] outputStrings = new string[] { "test1", "test2", "test3" }; //Option #1 StringBuilder formattedOutput = new StringBuilder(); foreach (string outputString in outputStrings) { formattedOutput.Append("prefix "); formattedOutput.Append(outputString); formattedOutput.Append(" postfix"); string output = formattedOutput.ToString();

iPhone, No Garbage Collection: What About MonoTouch?

瘦欲@ 提交于 2019-12-22 04:31:24
问题 It's well known that Apple does not provide automatic garbage collection on the iPhone to prolong battery life. Yet MonoTouch apps, which reportedly run perfectly on the iPhone (and many are sold through the AppStore, therefore are approved by Apple), do have automatic garbage collection. Is this automatic garbage collection, or does MonoTouch just manage all the retain/release stuff for you? If it is automatic garbage collection, wouldn't that be a drain on battery? Edit: If your answer to

Is there a way to git gc / prune on a remote Git repository hosted by TFS 2013?

依然范特西╮ 提交于 2019-12-22 04:26:07
问题 Over time the size of .git folder grows for Git repositories hosted on TFS 2013 (Update 4). Whenever cloning those repositories, .git folder can be huge in size initially, until git gc --aggressive --prune=now is performed manually. Microsoft says, that TFS 2013 does not perform git gc operations on its own. Unfortunately, it also seems impossible to force TFS to do that. Is there a way to gc/prune a Git repository hosted in TFS 2013 to reduce the initial size of .git directory? 回答1: Found

Can a conforming C# compiler optimize away a local (but unused) variable if it is the only strong reference to an object?

孤人 提交于 2019-12-22 03:37:10
问题 See also these related resources: Does the .NET garbage collector perform predictive analysis of code? (on Stack Overflow) WP7: When does GC Consider a Local Variable as Garbage (blog article on MSDN) In other words: Can an object referenced by a local variable be reclaimed before the variable goes out of scope (eg. because the variable is assigned, but then not used again), or is that object guaranteed to be ineligible for garbage collection until the variable goes out of scope? Let me

Force explicit deletion of a Java object

自古美人都是妖i 提交于 2019-12-22 01:56:18
问题 I'm working on a Java server that handles a LOT of very dense traffic. The server accepts packets from clients (often many megabytes) and forwards them to other clients. The server never explicitly stores any of the incoming/outgoing packets. Yet the server continually runs into OutOfMemoryException exceptions. I added System.gc() into the message passing component of the server, hoping that memory would be freed. Additionally, I set the heap size of the JVM to a gigabyte. I'm still getting

.NET 4.5: internal error in the .NET Runtime (80131506) / disabling concurrent GC

一世执手 提交于 2019-12-22 01:33:25
问题 I have a long-running .NET 4.5 application that crashes randomly, leaving the message I've mentioned in the question title in the event log. The issue is reproduced on 3 different machines and 2 different systems (2008 R2 and 2012). Application doesn't use any unsafe/unmanaged components, it's pure managed .NET, with the only unmanaged thing being the CLR itself. Here's the stack trace of the crash site that I've extracted from the dump: clr.dll!MethodTable::GetCanonicalMethodTable() clr.dll