garbage-collection

Garbage Collector too slow when working with large images

独自空忆成欢 提交于 2019-12-22 22:20:55
问题 I am using Emgu OpenCV to grab images from a webcam and want to visualize them with WPF Image Control. So I need to convert the image from Mat to something compatible with Image control. So I took this class from the Emgu examples: public static class BitmapSourceConvert { /// <summary> /// Delete a GDI object /// </summary> /// <param name="o">The poniter to the GDI object to be deleted</param> /// <returns></returns> [DllImport("gdi32")] private static extern int DeleteObject(IntPtr o); ///

Strange behaviour while Unit testing for memory leak using WeakReference

假装没事ソ 提交于 2019-12-22 19:18:14
问题 I'm trying to write a unit test for testing a memory leak. Steps to Reproduce: TestClass test = new TestClass(); WeakReference reference = new WeakReference(test, true); test = null; GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); Debug.Assert(reference.Target == null, "Memory Leak"); // This works //Replacing the above line with following, I see "Memory Leak" being printed. if (reference.Target != null) { Console.WriteLine("Memory Leak"); } I added a finalizer: ~TestClass() {

FB Profile says “it is a gc root”, but it seems wrong?

感情迁移 提交于 2019-12-22 17:38:56
问题 People like flash builder profile tool very much.But recently, a problem came to me when I tried to find a memory leak. Here is the simplified sample. package { import flash.display.Sprite; import flash.sampler.pauseSampling; import flash.system.System; import org.robotlegs.base.ContextBase; import org.robotlegs.mvcs.Context; public class MemoryLeak extends Sprite { public function MemoryLeak() { makeAndDrop(); } public function makeAndDrop():void{ var _context : Context = new Context(this);

Do I win memory by explicitly disposing imageView.Image?

戏子无情 提交于 2019-12-22 17:35:24
问题 I have this code in my app: var newImage = // ... if (imageView.Image != null && imageView.Image != newImage) imageView.Image.Dispose (); imageView.Image = newImage; I have three related questions: Does it immediately release the memory occupied by the previous imageView.Image ? If it does, is there a cleaner solution? Does this have anything to do with NSAutoreleasePool ? 回答1: Does it immediately release the memory occupied by the previous imageView.Image? Not immediately but it should be

Why python doesn't have Garbage Collector thread?

梦想的初衷 提交于 2019-12-22 17:20:12
问题 Java has daemon thread to monitor memory usage and do the gc task. From jstack I see "main" #1 prio=5 os_prio=0 tid=0x00007f34b000e000 nid=0x808 waiting on condition [0x00007f34b6f02000] java.lang.Thread.State: TIMED_WAITING (sleeping) at java.lang.Thread.sleep(Native Method) .... "GC task thread#0 (ParallelGC)" os_prio=0 tid=0x00007f34b0023000 nid=0x809 runnable "GC task thread#1 (ParallelGC)" os_prio=0 tid=0x00007f34b0024800 nid=0x80a runnable "GC task thread#2 (ParallelGC)" os_prio=0 tid

Why python doesn't have Garbage Collector thread?

﹥>﹥吖頭↗ 提交于 2019-12-22 17:20:07
问题 Java has daemon thread to monitor memory usage and do the gc task. From jstack I see "main" #1 prio=5 os_prio=0 tid=0x00007f34b000e000 nid=0x808 waiting on condition [0x00007f34b6f02000] java.lang.Thread.State: TIMED_WAITING (sleeping) at java.lang.Thread.sleep(Native Method) .... "GC task thread#0 (ParallelGC)" os_prio=0 tid=0x00007f34b0023000 nid=0x809 runnable "GC task thread#1 (ParallelGC)" os_prio=0 tid=0x00007f34b0024800 nid=0x80a runnable "GC task thread#2 (ParallelGC)" os_prio=0 tid

HashMap and garbage collection: do I need to call clear() before variable re-assignment?

℡╲_俬逩灬. 提交于 2019-12-22 13:58:40
问题 Maybe it's a silly question but I'm not sure about the garbage collection process. Consider this code: private HashMap<String, Parameter> configuration = new HashMap<String, Parameter>(); ... //add some items to configuration ... //now get another configuration HashMap<String, Parameter> parameters = new HashMap<String, Parameter>(); for (String parameterName : configurationParameterNameList) { parameters.put(parameterName, reader.readParameter(parameterName)); } //and reassign the variable

Howto easily monitor usage of Eden and Survivor Spaces

前提是你 提交于 2019-12-22 13:58:09
问题 What is the best way howto monitor usage of Eden and Survivor heap spaces? I have all the GC logging options on but I can see only YoungGen occupation: -XX:+PrintTenuringDistribution -XX:+UnlockDiagnosticVMOptions -XX:+LogVMOutput -XX:LogFile=jvm.log -server -XX:+HeapDumpOnOutOfMemoryError -XX:+DisableExplicitGC -Xloggc:gc.log -XX:+PrintGCTimeStamps -XX:+PrintGCDetails -showversion -XX:+PrintClassHistogramBeforeFullGC -XX:+PrintClassHistogramAfterFullGC -XX:+UseParallelOldGC -XX

Java Substring memory leak

拜拜、爱过 提交于 2019-12-22 12:21:04
问题 Based on the discussion about getting substring of String Java String.split memory leak? , I have been analyzing two sample substring examples of usage. It is said that objects don't get garbage collected if the caller stores a substring of a field in the object. When I run the code I get and OutofMemory Exception, and see the incresing of char[] allocated size while monitoring it via VisualVM public class TestGC { private String largeString = new String(new byte[100000]); String getString()

Garbage collection and GCHandle.Alloc

我们两清 提交于 2019-12-22 11:23:47
问题 void Foo() { System.Windows.Forms.Form f = new System.Windows.Forms.Form(); f.Show(); } To my understanding f holds the reference to the Form. But f is a local variable and it will go out of scope when the control leaves the curly braces. But the Form is still open. I tried calling GC.Collect(), but the Form is still open. One more scenario. private void button2_Click(object sender, EventArgs e) { Timer t = new Timer(); t.Enabled = true; t.Interval = 1000; t.Tick += new EventHandler(t_Tick);