memory-management

stringwithformat gives memory leak

I have written code as given below strPageText=[NSString stringWithFormat:@"%@%@",strPageText,data]; This is in loop. it gives me a memory leak error. ...

NSObject PerformSelector Issue

Hooooookay so here's another "I just have no idea what's going on" problem: The first time I make a call to getFullWL() below, I get all my values as expected. Each subsequent call, however, returns nan instead of the true value(-nan(0x400000000) in XCode or something) Furthermore, if I put my "debug" lines in SFLog the value prints a...

Memory access by multiple threads

Hi all. I'm writing a multi threading java application that runs on Nehalem processor. However I have a problem that starting from 4 threads I almost don't see the speedup in my application. I've made some simple test. I've created a thread that just allocates a big array and making access to random entries in the array. So when I run ...

Strange Objective-C problem

My app has a navigation controller and two views, firstController and secondController. firstController has a webView that displays an html page with links, and clicking any link will take the user to secondController. This is where the program stops by stepping through the debugger. See code below. - (BOOL)webView:(UIWebView *)webView...

Objective-C: Do you have to dealloc property objects before deallocating the parent object?

Let's say I have an object named "foo" with another object named "bar" as property. When "foo" deallocates, will it automatically remove all references to "bar" so that "bar" deallocates as well? or will "foo" deallocate and "bar" float in memory somewhere? even if all of "bar"'s references are defined in "foo". thanks in advance. ...

How to properly unload/destroy a VIDEO element

I'm working on a realtime media browsing/playback application that uses <video> objects in the browser for playback, when available. I'm using a mix of straight javascript, and jQuery, My concern is specifically with memory. The application never reloads in the window, and the user can watch many videos, so memory management becomes ...

Instruments - leaks in iPad app

Running Instruments on my iPad app found 2 leaks, except I cannot understand where they are coming from. The first one is in this method in my app delegate: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [window addSubview:self.viewController.view]; // <--- it leak...

Can I read a dynamical length variable using fread without pointers?

I am using the cstdio (stdio.h) to read and write data from binary files. I have to use this library due to legacy code and it must be cross-platform compatible with Windows and Linux. I have a FILE* basefile_ which I use to read in the variables configLabelLength and configLabel, where configLabelLength tells me how much memory to alloc...

alloc + init with synthesized property - does it cause retain count to increase by two?

I've seeen the following snippet quite a bit: In the header: SomeClass *bla; @property(nonatomic,retain) SomeClass *bla; In the implementation file: @synthesize bla; and then self.bla = [[SomeClass alloc] init]; I think that this assignment puts the retain count for 'bla' up by two; once through the alloc/init call, then throug...

Is there a way to test for an invalid memory location?

In a language like C, for example, if a routine receives a pointer, is there any system call or other test that can be applied to the pointer to check that it is a valid memory location, other than catching SIGSEGV or equivalent? ...

Is it possible to free memory using an offset pointer?

Let's say I have an allocation in memory containing a string, "ABCDEFG", but I only have a pointer to the 'E'. Is it possible, on win32, to free that block, given a pointer that is within the block, but not at the start? Any allocation method would work, but a Heap* function would be the path of least resistance. If not a native solutio...

Objective-C: Is there any way to find out what kind of object resides at a particular memory address?

Coming from Java and Python, I am not so well versed in memory management, but is there any way to find out what kind of object resides at a particular memory address? I am asking because my application terminated with a cryptic message that reads: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSD...

objective-c memory management question

I've people who use [variable release] and some other times variable = nil to clean up memory? When do you use each one? and what are the differences? ...

Objective-C : Why is my retain count not 1?

I have this very simple program where I just create an object and look at the retain count. #import <Foundation/Foundation.h> #import "GeometryCalculator.h" int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; GeometryCalculator *calculator = [[GeometryCalculator alloc] init...

Objective-C NSString Transformable attribute memory leak

I have a CoreData NSManagedObject subclass, TextNarration, that has an attribute of type NSString, textURI. That class implements the NSCoding protocol methods: initWithCoder and encodeWithCoder this way: - (id) initWithCoder: (NSCoder *)coder { if (self = [super init]) { self.textURI = [coder decodeObjectForKey:@"te...

Void* pointer problem

Pretty new to c++, i have a rather (i think) stupid question about a piece of code : class DataStream { protected: DataStream(void) { }; public: DataStream(int Length); ~DataStream(void); ... void* DataPtr; int Length; }; I do have a class similiar to this and i want to assign to DataPtr a pointer to some data allocated. When i...

Question about releasing an ivar with the Copy property

If I have a class @interface Foo { NSString *temp; } @property(nonatomic, copy) NSString *temp; @end I understand that upon assignment, the old temp will get released and the new one will be assigned using temp = [newTemp copy]. And going by memory management rules, you are supposed to do [temp release] in the dealloc method of...

Do I need to release a gesture recognizer?

If I add a gesture recognizer to a table cell called cell, e.g.: UILongPressGestureRecognizer *_longPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(cellGestureRecognized:)]; _longPressRecognizer.allowableMovement = 20; _longPressRecognizer.minimumPressDuration = 1.0f; [cell addGestureRecogniz...

UITableView custom class huge leak

Hi, I am using a custom class to display some info on a table view. The problem is that as long as I scroll the tableview memory is leaking... I guess I have something wrong at my class. Please have a look: @interface Person : NSObject { NSString *name; NSString *surname; NSString *address; NSString *email; } @property (n...

Progamming / memory / logical issue in code

Can you tell me is there any thing wrong in the code, my application is crashing randomly I cannot find any possible logical or memory error, please help as this is going out of my scope. #define __FN__ "CGD9_gd_ParseAddFieldsProC" int CGD9_gd_ParseAddFieldsProC (CGD_gd_ParseAddFields_Iparam_t *i_param_st_p) { t_gd9adfld_t *p_ext_fi...