memory-leaks

Objective C: Memory Leak of Dictionary used in singleton..

I am using a singleton class to share data between views in my iphone app. My singleton class contains a dictionary which I allocate in my -init method: - (id)init { if ( self = [super init] ) { self.dataList = [[NSMutableDictionary alloc]init]; } return self; } I release it in my dealloc metho...

vector of pointer to object - how to avoid memory leak?

Hi gentlemen, How do we ususaly deal with a vector whose elements are pointers to object? My specific question is the comment at the end of the code supplied below. Thanks. class A { public: virtual int play() = 0 ; }; class B : public A { public: int play() {cout << "play in B " << endl;}; }; class C : public A { public: int...

Problem with finding leak code

I am using xcode 3.2 and I have leaks in my app but how can I find the line in my code which is leaking?? In earlier version of xcode I just used to double click on the object in the instrument which used to show the xcode with pointing the line with the leak. But in the 3.2 version I am not able to do that. Please anyone tell me how to...

gSOAP C++ client memory leak

I have read the gSOAP docs and seen mentions of the fact that one should call soap_destroy(soap) and soap_end(soap) etc., however they are always examples with a single invocation on the service object. The service I am using returns about 40KB of text with each invocation. My problem is that memory usage grows linearly by about the same...

Static code memory leak detection for visual studio vc++

Hello, is there a way to detect simple memory leaks like this one with a static analysis tool? I cannot change the code to include the tipical includes used in runtime memory leak detection (struc1 is a simple structure with some fields). void noRelease(void) { struc1 *memoryLeak; memoryLeak = (struc1 *) malloc(sizeof struc1);...

A basic question about dealloc/release: is it always OK to do x = nil; [x release]; - or can it cause probems?

Hello, since every assignment to a variable with a different object increases its retain count and in the dealloc its not always clear how often a variable got assigned a simple [maVar release] might NOT BE SUFFICIENT. So using ALWAYS myVar = nil sets the retain count to zero, and a subsequent [myVar release] will never cause a problem...

xcode Build and Analyze related questions

Hi I was watching the videos from WWDC 2010 and have now started to dig in to the functionality of the Build and Analyze tool in xcode 3.2. It's a great tool that will highlight coding mistakes (specially for a newcomer like me!) even if they may not have an impact during runtime. But there is one thing I would need some help to unders...

Trying to free allocated memory borrowed when initializing an object, but getting Xcode warning

OK, so I have my main.m program code, and mvds suggested I free the allocated memory I borrowed from my class when I created a new instance. For some reason, when I attempt to free the memory using [converter free]; It gives me a warning saying that converter may not respond to -free, and once I finish my program, it spits out a bun...

Javascript / jQuery - How do I find the memory leak in my large amount of code?

I've written a lot of code for a website I'm developing and only just now realised it has a memory leak. I noticed Firefox getting rather slow over the day and checked my task manager to find it idling at 600,000 K. Seemed odd and so I killed it/restarted it. Then realised that, while watching the task manager, the more I played around ...

How precise is Task Manager?

I have a C++ Application, when I observe Task Manger, it shows that applicaiton's memory usage increases gradually. I manually check my source code, and I used Visual Leak Detector for Visual C++ to find memory leak, but I couldn't find any. Is it 100% that there is a memory leak, and I couldn't find it or is there any possibility that ...

VBscript to monitor system performance leaks memory

I have a simple script that monitors processes' different performance statistics in Windows XP in a loop until it is terminated. Despite my efforts, the script's memory footprint increases in size over time. Any advice is greatly appreciated. Set fso = CreateObject("Scripting.FileSystemObject") logFileDirectory = "C:\POSrewrite\data...

Having problems analyzing a .dmp with WinDBG

Hi All, I will start by saying this is the first time I have done anything with WinDbg so excuse my silly mistakes if that is the issue. My website has been using a lot of memory and after reading blogs and watching videos by Tess Fernandez I am trying to use WinDBG to analyze my dump file. The setup: My web server is a Windows 2008 6...

Leaks on the phone but not on the emulator?

Hey all, I have a problem and I'd like some advice. I'm working on a document viewer that's composed of the following major parts: zip library which unpacks the document container (minizip) xml library which parses the document (libxml2) UI code which renders the document on screen Nothing too complicated or fancy. On the emulato...

Managed C++ Memory leak

Hi, I am getting a memory leak whenver a new RPC thread in a DCOM server (c++ DCOM server) invokes the following managed C++ method void CToolDataClient::SetLotManagerActive(bool bLotManagerActive) { if( m_toolDataManager != nullptr) { m_toolDataManager->LotActive = bLotManagerActive; } } I get the managed C++ object point...

.NET version of Java's assertGC: Unit tesing memory leaks

I am trying to write a unit test using .NET 4 to ensure that an object can be garbage collected after some code is run. In Java, I would use assertGC to ensure that a weak reference is collected. How can I write this type of test for .NET? I have tried keeping a WeakReference to the object and calling GC.Collect(), but as you'd expect, ...

Best time to invalidate NSTimer inside UIViewController to avoid retain cycle

Does any one know when is the best time to stop an NSTimer that is held reference inside of a UIViewController to avoid retain cycle between the timer and the controller? Here is the question in more details: I have an NSTimer inside of a UIViewController. During ViewDidLoad of the view controller, I start the timer: statusTimer = [NS...

detecting memory leaks in C++ / windows

For debugging purposes, when I'm writing an app, the first thing I do is put the following into the stdafx.h: // -- leak detection ---------------------------------------------------------- #ifdef _DEBUG // http://msdn.microsoft.com/en-us/library/e5ewb1h3(v=VS.80).aspx #define _CRTDBG_MAP_ALLOC #include <stdlib.h> #include <crtdbg...

Memory leak for UIImageView?

I did the the following steps: Create a view-based iPad application in Xcode, Open the .xib file, add an UIImageView, set an image for it(a 200x100 image). Launch the program by Run>Run with performance tool>Leak And there are two leaks reported: Leaked Object # Address Size Responsible Library Responsible Frame Malloc 128 Byt...

Does this Objective-C code leak memory?

One thing I'm concerned about is I create two ints, but don't release them. Would it be better to make them NSIntegers? -(void) flipCoin { int heads = [headsLabel.text intValue]; int tails = [tailsLabel.text intValue]; if (random() %2 ==1 ) { heads++; } else { tails++; } headsLabel.text...

Autorelease Drowning

I came across a problem that seems to be called "drowning" in autorelease pools. My code creates and destroys objects correctly. However, I use some class methods that autorelease several variables without my knowing about it. Considering they loop thousands and thousands of times every minute... I find myself drowning in thousands of u...