memory-leaks

C# Explicitly Removing Event Handlers

Hi, I was wondering if setting an object to null will clean up any eventhandlers that are attached to the objects events... e.g. Button button = new Button(); button.Click += new EventHandler(Button_Click); button = null; button = new Button(); button.Click += new EventHandler(Button_Click); button = null; etc... Will this cause a...

std::auto_ptr, delete[] and leaks

Why this code does not cause memory leaks? int iterCount = 1000; int sizeBig = 100000; for (int i = 0; i < iterCount; i++) { std::auto_ptr<char> buffer(new char[sizeBig]); } WinXP sp2, Compiler : BCB.05.03 ...

How to identify, fix, closure memory leak in Windows Sidebar gadget?

i've written a gadget for Windows Sidebar. This essentially means that it is a miniature web-page, that runs for months on end. After a few weeks the memory usage (working set) of the sidebar.exe process that houses 3rd party gadgets runs into the hundreds of megabytes. Without a way to identify the source of memory leaks, i simply as...

Avoiding Scala memory leaks - Scala constructors

Hi! I was working through the "Programming in Scala" book, and was struck by a bit of a problem in the implementation of the class Rational in Chapter 6. This is my initial version of the Rational class (based on the book) class Rational(numerator: Int, denominator: Int) { require(denominator != 0) private val g = gcd(numerator.a...

Testing memory usage which tool?

Currently we are using Rational Purify, however it is a pain to use and we have now reached the stage where we are unable to instrument our applications without changing our development build system. The our application is statically linked and large. It is also memory hungry, where peak memory usage is often over 3Gb. Ideally I would ...

C: Returning a pointer to an automatic variable

Say you have the following function: char *getp() { char s[] = "hello"; return s; } Since the function is returning a pointer to a local variable in the function to be used outside, will it cause a memory leak? P.S. I am still learning C so my question may be a bit naive... [Update] So, if say you want to return a new char[]...

Where is the memory leak in this C++?

I have been told be a couple of tools that the following code is leaking memory, but we can't for the life of us see where: HRESULT CDatabaseValues::GetCStringField(ADODB::_RecordsetPtr& aRecordset, CString& strFieldValue, const char* strFieldName, const bool& bNullAllowed) { HRESULT hr = E_FAIL; try { CO...

memory leak on mdi with blank child form

Hi, I've created a blank application with a mdi parent form opening a blank child form from the menu. When the parent form of the child form is set to the mdi - it appears the system does not release memory - thus a leak. When the parent form is not set, the child form is removed. Does anyone know why this apparent memory leak can be...

Is it possible to 'see' the object graph for garbage collection?

I have a Java application that is leaking memory. I know which objects are not being freed during garbage collection, but I can't work out what is referencing them. Is it at all possible to have some sort of visibility of the object graph that is being held internally by the JVM? It is at all otherwise possible to find out which object...

Python leaking memory while using PyQt and matplotlib

I've created a small PyQt based utility in Python that creates PNG graphs using matplotlib when a user clicks a button. Everything works well during the first few clicks, however each time an image is created, the application's memory footprint grows about 120 MB, eventually crashing Python altogether. How can I recover this memory afte...

memory leak problem using NSData in iPhone

Memory leak problem - NSConcreteData // to set tip - photo in photo frame NSData *data=[NSData dataWithContentsOfURL:[NSURL URLWithString:pathOfThumbNail]]; UIImage *cellThumbImg; if([data length]>0){ cellThumbImg=[UIImage imageWithData:data];} else { cellThumbImg=[UIImage imageNamed:@"130X90.gif"]; } UIImageView *imgView=[[UIImage...

Detecting Memory Leaks in ActionScript-3 Project.

Hi! Is there any way to detect memory leaks in Flash ActionScript-3 project? what are the easier ways to achieve this in existing project ? ...

Implement object-caching in classic ASP memory-leaking

I have tried to implement different caching-implementations in a classic ASP site in order to offload the database during heavy traffic. My approach was this: Create a global HashTable object in global.asa where I later on store jscript-objects within <object id="SIZE_LIST" progid="System.Collections.HashTable" runat="Server" scope="A...

Will using goto cause memory leaks?

Hello everyone, I have a program in which i need to break out of a large bunch of nested for loops. So far, the way most people have been telling me to do it is to use an ugly goto in my code. Now, if i create a bunch of local stack (i think that's what they are called, if not, i mean just regular variables without using the new comma...

How to use IE7 Javascript memory leak detectors?

I downloaded the "Javascript Memory Leak Detector" for IE mentioned elsewhere on SO and also here but cannot figure out how to use it. Apparently there used to be another blog post that perhaps went into this detail, but the link to it from the above link is broken. I've also tried using sIEve and it does a decent enough job except tha...

Memory leak question in C after moving pointer (What exactly is deallocated?)

Hi! I realize the code sample below is something you should never do. My question is just one of interest. If you allocate a block of memory, and then move the pointer (a no-no), when you deallocate the memory, what is the size of the block that is deallocated, and where is it in memory? Here's the contrived code snippet: #include <std...

How am I leaking memory?

I have a table view that when loading creates a person object Person.h #import <UIKit/UIKit.h> #import "TwitterHelper.h" @interface Person : NSObject { NSDictionary *userInfo; NSURL *image; NSString *userName; NSString *displayName; NSArray *updates; } /* @property (retain) NSString *userName; @property (retain) NS...

What are the Finalizer Queue and Control+ThreadMethodEntry?

I have a WindowsForms app that appears to leak memory, so I used Redgate's ANTS Memory Profiler to look at the objects I suspect and find that they are only held by objects already on the Finalizer Queue. Great, exactly what is a the Finalizer Queue? Can you point me to the best definition? Can you share any anecdotal advice? Also, all ...

delete[] and memory leaks

Hi, I am wondering about the delete[] operator in C++. (I am using Visual Studio 2005). I have an unmanaged DLL that is being called by a managed DLL. When I close this program after performing a few tasks while debugging, I am getting many (thousands?) of memory leaks, mostly 24 bytes - 44 bytes in size.. I suspect it might be due to a...

How to determine where this memory leak is coming from?

How can I determine where this memory leak is coming from in my code? It doesn't reference anything but the "main" function in my application. ...