memory-management

Objective-C memory management strange results

I am calling a function repeatedly with a loop, and the loop runs inside of a thread. The thread has an autorelease pool. I have the following code inside that function: NSXMLDocument* undoXML; NSData* undoData = [NSData dataWithContentsOfFile:undoFilePath]; undoXML = [[NSXMLDocument alloc] initWithData:undoData opti...

Memory leak in XML Parser

Hi everyone I use NSXMLParser for parsing an XML document. I have the following functions (among others): - (void) parserDidStartDocument:(NSXMLParser *)parser { // Init tempString tempString = [NSMutableString string]; } - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)n...

Why is my application pool having memory usage spikes?

I hosted my application in production. Within 5 to 6 hours the application pool spikes and uses more memory? What application objects or system objects are stored in the application pool? ...

Where should a class free its private variables?

As there is no garbage collection in Delphi, where exactly do you unload variables? Say I have a type with a set of private vars. Would it suffice to have a Destroy method that does this work? Do I need to explicitly call this destroy method in my consuming classes? ...

Java using too much memory on Linux?

I was testing the amount of memory java uses on Linux. When just staring up an application that does absolutely NOTHING it already reports that 11 MB is in use. When doing the same on a Windows machine about 6 MB is in use. These were measured with the top command and the windows task manager. The VM on linux I use is the 1.6_0_11 one, a...

Why is my Cocoa app using so much virtual memory?

I have written a simple Cocoa app. In Activity Monitor, it is shown to be using a lot more virtual memory than all other apps: 304.6MB. (It uses this from the get-go, so I don't think it's a memory leak/management issue). Thing like Firefox, Mail etc. are only using 30MB-60MB or so. My app is using 13MB real memory. I am using garbage c...

Virtual Size and GlobalMemoryStatusEx

Hi, guys, My system is Windows XP. Virtual Size displayed in TaskManager is different with MEMORYSTATUSEX.ullAvailVirtual got from GlobalMemoryStatusEx. When I create lot of buffers and the memory usage is up, MEMORYSTATUSEX.ullAvailVirtual can well reflected the virtual size usage. It's same. But when I delete the memory, Virtual Siz...

NSString basics - memory - retain - copy

Here is my question. NSString *xyz=[NSString stringWithFormat:@"%i %@",10,@"Sagar"]; Now I am taking other string, as follows. NSString *x2=[xyz copy]; I exactly don't know what will happen here? ( Is it something like, x2 has the ref of xyz's ref. ) NSString *x3=[xyz retain]; ( What will happen here, x3 has a new memory having...

is it possible to free memory of UIWebView?

i'm trying to release UIWebView object but it not free memory. is it have any reason? ...

How to guard against memory leaks?

I was recently interviewing for a C++ position, and I was asked how I guard against creating memory leaks. I know I didn't give a satisfactory answer to that question, so I'm throwing it to you guys. What are the best ways to guard against memory leaks? Thanks! ...

How do I check if my object is properly disposed?

I wonder if there a "trick" that permits to know if the used objects in a portion o code has been properly(entirely) disposed, or, in other words don't creates memory leaks. Let's say I have a container of GDI objects (or other that I need to explicitly dispose) public class SuperPen { Pen _flatPen, _2DPen, _3DPen; public Sup...

Using RAII with a character pointer.

I see a lot of RAII example classes wrapping around file handles. I have tried to adapt these examples without luck to a character pointer. A library that I am using has functions that take the address of a character pointer (declared like get_me_a_string(char **x)). These functions allocate memory for that character pointer and leave ...

How to avoid successive deallocations/allocations in C++?

Consider the following code: class A { B* b; // an A object owns a B object A() : b(NULL) { } // we don't know what b will be when constructing A void calledVeryOften(…) { if (b) delete b; b = new B(param1, param2, param3, param4); } }; My goal: I need to maximize performance, which, ...

Why am I crashing after MKMapView is freed if I'm no longer using it?

I have a MKMapView. Sometimes after my view controller is dismissed, I'll get a EXC_BAD_ACCESS. I turned on NSSZombies and it looks like the MKMapView's delegate — my view controller! — is being called, despite both the MKMapView and UIViewController subclass being freed. I've checked, and my memory management is correct. What's going ...

How is release handled for @synthesized retain properties?

I have some questions about synthesized properties in Objective-C. The full list follows, but the basic question is this: How does the compiler ensure that the ivars for synthesized properties are properly released, even though my code may or may not include release methods in dealloc? Note: I decided not to post these as individual que...

Memory usage of the current Flex/Actionscript application

System.totalMemory shows the memory usage of the all instances of all flash/AIR applications in the system. Is there a way to find the memory usage of only the current application? Also even if I have only one instance of an application, and I close/relaunch it several times, System.totalMemory increases almost exponentially. ...

calloc and copying data into memory area using c

I'm trying to allocate a block of memory and then copy data into that space. I made this simple program and it doesn't do what I expect it to do. Could someone please point out my faulty reasoning. Thanks. #include <stdio.h> #include <stdlib.h> void main(void) { int t1 = 11; int t2 = 22; int *bufptr; bufptr = calloc(2, sizeof(int)); ...

-(void)dealloc = How?

Hello ! every one. I have a little query regarding the memory management. Let's begin with an example. Assume we have a class as follows. @interface myClass : NSObject { NSString *xyz; } @end Now, see the implementation. @interface myClass : NSObject { NSString *xyz; } @end @implementation myClass -(void)abc{ // xyz a...

Is is possible to replace the memory allocator in a debug build of an MFC application?

Background: I'd like to make use of Electric Fence in an MFC application. I'd like to track new/delete, and if I can track malloc/free that's an added bonus. Unfortunately, MFC redefines new and delete - but using macros (DEBUG_NEW) - so I can't use the standard C++ method of redefining them. (MFC defines them to have different signatur...

Objective-C++ Memory Problem

Hello, I'm having memory woes. I've got a C++ Library (Equalizer from Eyescale) and they use the Traversal Visitor Pattern to allow you to add new functionality to their classes. I've finally figured out how it works, and I've got a Visitor that just returns the properties from one of the objects. (since I don't know how they'r...