memory-management

Delete array of size 1

This is possibly a candidate for a one-line answer. I would like know it anyway.. I am writing a simple circular buffer and for some reasons that are not important for the question I need to implement it using an array of doubles. In fact I have not investiated other ways to do it, but since an array is required anyway I have not spent ...

How to optimize paging for large in memory database

I have an application where the entire database is implemented in memory using a stl-map for each table in the database. Each item in the stl-map is a complex object with references to other items in the other stl-maps. The application works with a large amount of data, so it uses more than 500 MByte RAM. Clients are able to contact th...

EXC_BAD_ACCESS on iPhone (with debugger screenshot)

Hello. I'm developing an iPhone application that show the camera's view with this code: -(void) displayAR { [rootViewController presentModalViewController:[self cameraController] animated:NO]; [displayView setFrame:[[[self cameraController] view] bounds]]; } And hide the camera's view with this code: - (void) hideAR { [[...

Losing NSManaged Objects in my Application

I've been doing quite a bit of work on a fun little iPhone app. At one point, I get a bunch of player objects from my Persistant store, and then display them on the screen. I also have the options of adding new player objects (their just custom UIButtons) and removing selected players. However, I believe I'm running into some memory ma...

Updating a deallocated UIWebView from a background thread

(Two edits follow the original body of this question, both of which modify the question pretty radically. Don't get hung up on the first part of this--while useful for contextual purposes, I've all but ruled out the original problem I was asking about.) As you can see from the title, I've programmed myself into a corner and I've got sev...

Incorrect decrement of the reference count

I have the following problem: In one flow of the execution I use alloc, and on the other flow, alloc is not needed. At the end of the if statement, in any case, I release the object. When I do 'build and Analize' I get an error: 'Incorrect decrement of the reference count of an object is not owned by the caller'. How to solve that? UII...

Unload image of UIImageView thats offscreen

Hi, I'm coding an application on Ipad, in a certain point of my application I present a ViewController with the presentModalViewController. My ViewController is a UISScrollView who take the larger of the modalView and inside it I display some images, I allow pagingEnabled so I can see all my images inside the scrollView. Sometimes I ...

How UIWindow#addSubview can make memory leak?

Hello, I started to learn using Instrument, but I cannot figure it out. After I start my application, the UI shows up, I do nothing and after few seconds I can see memory leak detected: When I have a look at the second leak I can see the following stack: When I double click on the cell related to my code I can see that it is pointin...

C when to allocate and free memory - before function call, after function call...etc

I am working with my first straight C project, and it has been a while since I worked on C++ for that matter. So the whole memory management is a bit fuzzy. I have a function that I created that will validate some input. In the simple sample below, it just ignores spaces: int validate_input(const char *input_line, char** out_value){ ...

I need help with iPhone memory management and am willing to pay

I am looking for a Los Angeles based iPhone developer that would be willing to help tutor me on memory management and run down some code. Will pay for your time. Thanks, Sam ...

Should I release NSURL?

Hello, I have the following code: + (BOOL)updateStatus:(NSString *)status forUsername:(NSString *)username withPassword:(NSString *)password { NSURL *loginURL = [NSURL URLWithString:@"XYZ"]; ASIFormDataRequest *loginRequest = [[ASIFormDataRequest requestWithURL:loginURL] retain]; [loginRequest setPostValue:@VALUE forKey:@"SOME_KE...

C++: Delete a struct?

I have a struct that contains pointers: struct foo { char* f; int* d; wchar* m; } I have a vector of shared pointers to these structs: vector<shared_ptr<foo>> vec; vec is allocated on the stack. When it passes out of scope at the end of the method, its destructor will be called. (Right?) That will in turn call the destr...

Do I need to retain autoreleased objects?

Hello, I'm using ASIHTTPRequest library and I want to be sure if I use it in a good way from the memory management point of view. I create: ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:someUrl]; I guess that according to the naming convention I don't have to retain request object, right? but when I look at the cod...

how reference copy is handled in Objective-C?

Object graph [Instance A] tree / \ / \ / \ [Instance B] [Instance C] apple bug Question Instance A has to reference copies to Instance B and Instance C. If I retain or release Instance A, which has references to the other two instances, wha...

When a object can be released in the dealloc method in Objective-C?

Hi, What is the difference of releasing the object outside and inside a dealloc method? When it will be appropriate to specify release of the object in the dealloc method, pls can u specify the differences... ...

Objective-C (iPhone) Memory Management

I'm sorry to ask such a simple question, but it's a specific question I've not been able to find an answer for. I'm not a native objective-c programmer, so I apologise if I use any C# terms! If I define an object in test.h @interface test : something { NSString *_testString; } Then initialise it in test.m -(id)init { _test...

Find out when all processes in (void) is done?

Hey. I need to know how you can find out when all processes (loaded) from a - (void) are done, if it's possible. Why? I'm loading in data for a UITableView, and I need to know when a Loading... view can be replaced with the UITableView, and when I can start creating the cells. This is my code: - (void) reloadData { NSAutoreleaseP...

NSMutableDictionary memory / address problem, release does not work?

I am trying to create a NSMutableDictionary(dictA) with objectA. When I try to view my dictionary(NSLog), each key is pointing to the same address. I have an objectA_1 which is type objectA and used to setup the dictionary. Also, if I try to getObject, I always get the last key/value that was added to the dictionary. I tried setValue...

Objective-C Memory Management: When do I [release]?

I am still new to this Memory Management stuff (Garbage Collector took care of everything in Java), but as far as I understand if you allocate memory for an object then you have to release that memory back to the computer as soon as you are finished with your object. myObject = [Object alloc]; and [myObject release]; Right now I ju...

Retain count problem iphone sdk

Hi all, I'm facing a memory leak problem which is like this: I'm allocating an object of class A in class B. // RETAIN COUNT OF CLASS A OBJECT BECOMES 1 I'm placing the object in an nsmutablearray. // RETAIN COUNT OF CLASS A OBJECT BECOMES 2 In an another class C, I'm grabbing this nsmutablearray, fetching all the elemen...