memory-management

free vs. dealloc vs. release

Hi guys, I am very new to obective C and Ipad app development. Can someone explain the difference between "free", "release", "autorelease" and "dealloc"? Thank you so much in advance. I realise this might be a simple question for the pros but I genuinely don't know where to use what. Thank you ...

In objective-C what's the difference between Type* var, and Type *var ?

Oh the joys of being a memory management noob ! I'm getting bit by some Objective-C code, eventhough I understand the basics of pointers, I've seen these two different constructs, without being able to really understand their difference. Can anyone enlighten me ? Edited my question, the constructs didn't behave differently, instead ...

iPhone basic memory management

Is this proper memory management? What I'm wondering is if I am supposed to release after the alloc in -viewDidLoad. SomeViewController.h #import <UIKit/UIKit.h> @interface SomeViewController : UIViewController { UIButton *someButton; NSString *someString; } @property (nonatomic, retain) IBOutlet UIButton *someButton; @prope...

Memory management when doing multitasking in iOS 4

According to Apple... apps should reduce their memory footprint as much as possible when running in the "background" (suspended mode). I reduce the memory footprint of my app by releasing a bunch of 2D textures in ApplicationDidEnterBackground and reloading the same textures in ApplicationWillEnterForeground. Everything works for the m...

Objective c memory leak.

Here are two methods that return a dictionary of my custom four-propery objects. They make arrays of strings, floats and BOOLs to put in the Chemical objects, then build a dictionary from the arrays. I'm new enough to the whole memory management game that I'm not always sure when I own something and when to release it. I'm making all ...

NSString's superclasses go on forever.

I've got a method that when put a breakpoint in it and hover over a string, says it's out of scope and you can drill down into the NSString object for what seems like forever. I've tried to put a screen shot... hope it shows up. I think I have some serious memory management problems... http://web.me.com/gazelips/Site/Blank_files/scree...

Research on banishing heap space issues?

We are putting together a platform that can supposedly load any jar file and run statistical models. The issue im facing right now is that some models run too big to fit on our platform causing heap out of memory errors. I know there has been research done on this but I cant find them anymore. In essence, how does google app engine do...

How to correctly fix "zero-sized array in struct/union" warning (C4200) without breaking the code?

I'm integrating some code into my library. It is a complex data structure well optimized for speed, so i'm trying not to modify it too much. The integration process goes well and actually is almost finished (it compiles). One thing is still bothering me. I'm getting the C4200 warning multiple times: warning C4200: nonstandard extension ...

NSString and NSData Memory Management

Hi guys, I have the following code for creating an NSString to contain the body of the text file and then convert it to NSData and output it to a file. NSString *particleString = [[NSString alloc] initWithFormat:@"%@", @"This is the body of my file"]; NSData *metaVals = [particleString dataUsingEncoding:NSISOLatin1Stri...

Constant Array and Memory Management

Hi, I have defined a constant array in one of my classes as: static const float values[] = {-0.5f, -0.33f, 0.5f, -0.33f, -0.5f, 0.33f,}; In the dealloc method of my class, do I need to free the memory occupied by this field? How do I do it? Should I use NSArrays instead? ...

Don't worry about `retainCount`? Really?

I've been told to not worry about retain counts. I understand that I shouldn't decide to release or retain using conditional logic based on retainCount, but should I not worry about it? I thought these correspond to memory usage in some way. For instance, if I have a bunch of subviews of UIView that I've also put into an NSArray to be a...

Which Java collection should I use to implement a thread-safe cache?

I'm looking to implement a simple cache without doing too much work (naturally). It seems to me that one of the standard Java collections ought to suffice, with a little extra work. Specifically, I'm storing responses from a server, and the keys can either be the request URL string or a hash code generated from the URL. I originally t...

CGDataProvider doesn't free up data on callback

Hi, I am creating a very big buffer (called buffer2 in the code) using CGDataProviderRef with the following code: -(UIImage *) glToUIImage { NSInteger myDataLength = 768 * 1024 * 4; // allocate array and read pixels into it. GLubyte *buffer = (GLubyte *) malloc(myDataLength); glReadPixels(0, 0, 768, 1024, GL_RGBA, GL_UNSIGNED_BYTE, buf...

How to manage memory on iPhone when handling many images

I have kind of a unique problem in the project I'm working in. What I'm doing is creating sort of a "wall" of scrollable images that are downloaded from a server that our user can flick through on the iPhone. But the problem is we're having trouble coming up with a good memory management plan here. What we have running right now is a cla...

How to deal with different ownership strategies for a pointer member?

Consider the following class structure: class Filter { virtual void filter() = 0; virtual ~Filter() { } }; class FilterChain : public Filter { FilterChain(collection<Filter*> filters) { // copies "filters" to some internal list // (the pointers are copied, not the filters themselves) } ~Filter...

Can I constrain a HashMap by the amount of memory it takes up?

I am implementing a simple cache using LinkedHashMap based on the instructions found here. I use the following code: public class Cache extends LinkedHashMap { private final int capacity; public Cache(int capacity) { super(capacity + 1, 1.1f, true); this.capacity = capacity; } protected boolean removeEldestEntry(Entr...

Memory Efficient Recursion

Hi, I have written an application in C# that generates all the words that can be existed in the combination of alphabets, numbers and few special characters. The problem is that it isn't memory efficient as it is adapting Recursion and also some collection like List. Is there any way I can make it to run in limited memory environment?...

NSXMLParser and memory management issues

I've been trying to implement NSXMLParser and so far I've had memory issues, performance issues or it doesn't work. I worked originally from a example off the net and it leaked a heap of memory. I released the objects properly but found that there was a performance hit because I would alloc and then release each object for each element....

Which object did send a "release" message to my property ?

Hi everyone ! There's something i don't seem to get about properties and memory management with iOS ! In my AppDelegate, i want a NSString * property : - i've declared it this way in the .h file : @property (nonatomic, copy) NSString *myString; - and synthetized it in the .m One of my method use the property like this : myString = ...

CGDataProvider and callback

Hi, I am creating a very big buffer (called buffer2 in the code) using CGDataProviderRef with the following code: -(UIImage *) glToUIImage { NSInteger myDataLength = 768 * 1024 * 4; // allocate array and read pixels into it. GLubyte *buffer = (GLubyte *) malloc(myDataLength); glReadPixels(0, 0, 768, 1024, GL_RGBA, GL_UNSIGNED_BYTE,...