memory-management

Effective C++: Item 52 and how to avoid hiding all normal operator new & delete versions.

Hi, At the end of Item 52 (Customising new and delete) in Myer's Effective C++ he discusses how to avoid hiding normal new and delete versions when implementing custom version as follows: If you declare any operator news in a class, you'll hide all these standard forms. Unless you mean to prevent class clients from using thes...

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...

Doing [obj release] on obj with retainCount=1 does not decrement retainCount to zero

Hi, I created a simple program to test the retain/release methods in Objective-C memory management. As I understand of ObjC memory management, I expect that a object with retain count = 1 on which I call release get the retain count decremented to zero and then released. But this test program show that after the first release I still ge...

Asynchronous Callbacks to Dismissed Viewcontrollers?

Have noticed issue while testing iphone app that if one quickly opens/dismisses a modal view which contains asynchronous http calls the app eventually freezes up with a EXC_BAD_ACCESS message. I'm relatively confident that there aren't any memory leaks in either the modal view or the viewcontroller that's launching it (at least none tha...

structure with linked-list memory dump

Hi, is there any standard approach which I've missed at school to dump C structure with nested linked lists on disk in reasonable way? What I don't want to do is: use protocol-buffers or any other like serializators, don't want to create JSON, XML or other I've few ideas: allocate accurate memory amount (or extend existing one) and...

Freeing memory allocated for a Tree - C

I have a tree defined like, struct tree { char label[MAX_LENGTH]; char value[MAX_LENGTH]; struct tree *child; struct tree *next; }; Now I need to free the memory allocated by this tree. I wrote the following code. unsigned int tree_free(struct tree *root) { struct tree *current = NULL, *next = NULL, *child = NULL;...

NSAutoreleasePool question

I drained an autorelease pool. The warning *** attempt to pop an unknown autorelease pool means the autorelease pool was created and drained in different methods - that's fine. But does it mean such pool is NOT being drained? Is there a solution? ...

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...

iphone object c is object already released

Hi, i release an image with [myimageview.image release]; but after the app was in background it comes foreground again it release that image again, so it crash! All my tries to check if the app came from a background did not worked. So how could i check if an object is already released.. so i dont do it twice? than...

Memory leaks in UICOLOR color with RGB method

Hi, I have to token the string and get a RGB values to make a UICOlor, below is the code, NSString* text = @"1.0,1.0,1.0"; NSArray *chunks = [text componentsSeparatedByString:@","]; return [UIColor colorWithRed:([[chunks objectAtIndex:0] floatValue]/256.0) green:([[chunks objectAtIndex:1] floatValue]/256.0) ...

release function in objective c

In Objective-C all objects can be released from memory using release function ? ...

Dealing with large amounts of data in c++

I have an application that sometimes will utilize a large amount of data. The user has the option to load in a number of files which are used in a graphical display. If the user selects more data than the OS can handle, the application crashes pretty hard. On my test system, that number is about the 2 gigs of physical RAM. What is a ...

Java: why does it uses a fixed amount of memory? or how does it manage the memory?

Hi, It seems that the JVM uses some fixed amount of memory. At least I have often seen parameters -Xmx (for the maximum size) and -Xms (for the initial size) which suggest that. I got the feeling that Java applications don't handle memory very well. Some things I have noticed: Even some very small sample demo applications load huge a...

Deallocating Direct Buffer Native Memory in Java for JOGL

Hello there, I am using direct buffers (java.nio) to store vertex information for JOGL. These buffers are large, and they are replaced several times during the application life. The memory is not deallocated in time and I am running out of memory after a few replacements. It seems that there is not good way to deallocate using java.n...

iPhone, memory issues with UIImage animations.

I have an AnimationManager class which cycles through UIImages to create a 14 frame animation. The application runs out of memory when the animations are played over and over. It was my understanding that I should not release UIImage. I do however, release the array containing the images. What can I do to reduce the memory used by the ...

OutOfMemory Error java heap space

I'm using this statement //some code int a[][]=new int[5000000][5000000]; //some code and running it with command java -mx512m Test It is giving OutOFMemoryError: Java Heap space indicating the line number of the mentioned statement in the stacktrace How do i solve this problem Edit: I'm trying to solve a practice problem on cod...

How should I manage memory for C block feature? (Apple extension)

Apple introduced a closure in C as name of 'block'. Should I manage memory for the blocks? If so, what do I have to do? ...

Saving on Instance Variables

Our server recently has been going down a lot and I was tasked to improve the memory usage of a set of classes that was identified to be the culprit. I have code which initializes an instance of an object and goes like this: boolean var1; boolean var2; . . . boolean var100; void setup() { var1 = map.hasFlag("var1"); var2 = map.has...

I can't understand a leak -- Possibly Instrument fail ?

I'm trying to fix some leaks in an iPhone app, but I'm still fighting w/ one of them. It appears with Instruments, and I can see something like : ImageIO 128 bytes (Leaked Object -> Malloc) But I'm releasing nearly all used object (at least I think), could it be a false positive or some memory leak for the ImageIO library ? I know th...

Can I see which objects are referencing a particular object?

I have a problem with objects not being deallocated. It would be of great help if I could find out what objects are still referencing the object that should be deallocated. How can I get such information? ...