memory-leaks

Why does Clang complain about all my autoreleased objects?

I have the following function: - (NSString *)urlEncodedValue { NSString *result = (NSString *)CFURLCreateStringByAddingPercentEscapes( kCFAllocatorDefault, (CFStringRef)self, NULL, CFSTR("?=&+/\r\n"), kCFStringEncodingUTF8 ); return [result autorelease]; } Why is Clang giving me the following c...

Finding cause of memory leaks in large PHP stacks

I have CLI script that runs over several thousand iterations between runs and it appears to have a memory leak. I'm using a tweaked version of Zend Framework with Smarty for view templating and each iteration uses several MB worth of code. The first run immediately uses nearly 8MB of memory (which is fine) but every following run adds ab...

Can gcc accurately catch useless conditionals?

Please examine the following code: if (foo->bar == NULL); foo->bar = strdup("Unknown"); I spent the last part of three hours hunting down that leak with Valgrind, feeling very silly when I discovered the bogus ';'. I know that the above code is valid C, however I would love for gcc to be able to tell me if I'm using a conditional ...

Running a groovy application under Maven

Hi! We have developed a Groovy application. Under development for starting it we use the following command line C:\myapp>mvn grails:run-app Without sending any request to the server one can see how the memory used by the java process in increasing and increasing. When it starts at about 100M are allocated and a couple of hours later...

Automated way to find JUnit tests that leak memory

The root of our problem is Singletons. But Singletons are hard to break and in the meantime we have a lot of unit tests that use Singletons without being careful to completely clear them in the tearDown() method. If figure that a good way to detect tests like these is to look for memory leaks. If the memory used after tearDown() and S...

Java server socket buffers not being garbage collected on Mac--why?

I'm hunting a memory error in an application, and it seems to be related to the byte[] buffers generated by ServerSocketChannel.accept(). According to jvisualvm, of the 505 megs in use by the application, over 90% of the memory is being used by byte[] arrays. Tracking it further, there are 68k+ instances of byte[] and by far the most c...

why are user controls not collected by Gargabe Collector?

I have a large .NET C# application with a memory leak. Using ants memory profiler, I can see that there are multiple versions of same user controls in memory and the garbage collector is not collecting them. There is output caching on the web forms but no output caching on the actual user controls. Is there a reason why the user contro...

Is it possible to disconnect all event handlers in Dojo?

Some code I am working with replaces some HTML elements that have Dojo event listeners with new HTML coming from an AJAX call (using .innerHTML=). I have read that event listeners should be disconnected using the dojo.disconnect(handle) method before they are replaced to prevent memory leaks. Is it possible to derive all handles connect...

Bitmap.Save, Huge Memory Leak

I have an application where I am taking a bitmap and compressing it using a GZipStream and sending it over a socket, all in memory. I have tracked down the dirty scumbag memory leak to the following line: frame.Save(inStream, jpegCodec, parameters); Browsing around the good ol' information superhighway I have found numerous topics abo...

Is there a way I can know who holds a reference to an object?

Is there a way I can know who holds a reference to an object? I see that my object is not finalized by the d'tor after I call GC.Collect. ...

Memory leaks in image creation function

Hi, I am currently working on an iPhone game, and need to create some animation on the fly. The animation is based on several images, and as the range of image combinations is too large and it is impossible to pre-create all of sequences, I'd like to be able to recalculate a set of images every time the situation changes. The function ...

VB -- Why Is This Causing a Memory Leak?

This is interesting. We've spent the last day attempting to patch a problem with the following (legacy) code that continues to grow its process size. This is done in Visual Studio 2003. We have a form on which we display an image (from MemoryStream) and some text and a button. Nothing fancy. Looks something like this: Protected Overr...

How to Fix the Memory Leak in IE WebBrowser Control?

I am trying to embed a WebBrowser Control in a C# Winform Application. This sounds easy enough. However I discovered that the WebBrowser control eats up a lot of memory every time I call the Navigate method. The memory is never released. The memory usage grows and grows… Many people on the net having the exact same problem but I haven’t...

Memory leak using JNI to retrieve String's value from Java code

i'm using GetStringUTFChars to retrieve a string's value from the java code using JNI and releasing the string using ReleaseStringUTFChars. When the code is run on JRE 1.4 then there is no memory leak but if the same code is run with a JRE 1.5 and higher version then the memory increases. This is a part of the code: msg_id=(*env)->GetS...

Swig / Python memory leak detected

I have a very complicated class for which I'm attempting to make Python wrappers in SWIG. When I create an instance of the item in Python, however, I'm unable to initialize certain data members without receiving the message: >>> myVar = myModule.myDataType() swig/python detected a memory leak of type 'MyDataType *', no destructor found....

Asp.Net Caching and memory leaks when removing items from Cache

So I'm trying to introduce some caching into my Asp.Net application. New data for the user is returned from the DB in the form of large datasets. Whenever a user requests data I insert this dataset into the HttpRunTime.Cache. At the moment I'm setting their caching time to 2-3 hours. And these are really large datasets and I put them in ...

.NET Resource Leak Gotchas

There are several ways that developers can get caught out by unintentional resource leaks in .NET. I thought it would be useful to gather them in one place. Please add yours with one answer per item, so the best get voted up :) ...

Does garbage collector clear objects subscribed to events?

If I do the following: public class Test { public static void Main() { List<Person> persons = new List<Person> { new Person() }; persons[0].Sneezing += new EventHandler(Person_Sneezing); persons = null; } public static void Person_Sneezing(object sender, EventArgs e) { (sender as Person).CoverFace(); } } Does the pers...

WPF ItemsControl: Where is my memory leak?

sample demo solution: http://cid-e8bbd1bbd58dbc88.skydrive.live.com/self.aspx/.Public/Stuff/GMapNET%20wpf%20leak%20test.zip image: Press END to add 1000 items and remove them. Any ideas where it is leaking memory? void MainWindow_PreviewKeyUp(object sender, System.Windows.Input.KeyEventArgs e) { if (e.Key == System.Windows.Input.K...

How to free memory from a looped object

I am trying to dynamically update a tooltip made with Prototip and Prototype. The way I am trying to do this is probably not the best way (so if you know a better way that would be helpful), but the only way i could think to do it would be to hold the javascript in a div element and update the javascript inside the div element in order ...