memory-management

A program to control memory for a task in C

Hi I have got a task to solve, that is a bit cryptic. The task is to make a program in C that handles texts messages, the program should simulate a system with a small amount of memory, the system should only be able to hold X messages with maximum X characters, every character takes 1 byte (ASCII). To manage messages should I make a sy...

ModalViewController based app crashes after 30 presentations

I have an ipad App, which has categories (tableviewcontrollers inside it) and detail views which has a webview shows info of the row on tableview. On didSelectRowAtIndexPath function of category table views i am using the code as: DetayViewController *dvc = [[DetayViewController alloc] init]; Blog *b = (Blog *)[self.blogArray objectAtI...

UINavigationController releasing bonanza

At the end of this code: UIViewController *viewController = [[UIViewController alloc] init]; UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController]; [viewController release]; [self presentModalViewController:navigationController animated:YES]; [navigationController relea...

Trying to reuse variable to avoid abandoned memory

I've got a TapDetectingImageView class that is pertaining in memory after usage because I do not reuse it in my code. I change my code now to reuse it instead of re creating a new one each time. The goal is to configure that TapDetectingImageView object and put it in a view. I'll do it 8 times but with the code below, only the last one ...

How to fix strange retain count (1 init - 3 retaincount)? + edit: dealloc problem

So my code goes like this: ArticleControllerController *ac = [[ArticleControllerController alloc] init]; ac.categoryIndex = idx; NSLog(@"acc retain: %d", [ac retainCount]); [app.nav pushViewController:ac animated:NO]; NSLog(@"acc retain: %d", [ac retainCount]); [ac release]; NSLog(@"acc retain: %d", [ac retainCount]); ...

UIViewController retain problem: count never reaches zero

Please, take a look at my code bellow. This part pops top view controller (usually, the same ArticleControllerController) from the stack (I found that the problem stays the same no matter if I pop single controller or pop to the root controller), creates new one and adds to the stack. The problem is, that its retain count never goes to ...

Which language has better memory management among C,C++,Java?

Hello All, I just wanted to know which language has better memory management among C,C++ and Java,why is it so and it is based on what criteria? I know that Java uses garbage collection for freeing memory and C uses DMA functions.Does this make java better at memory management since it's handled automatically? I do not know C++ so I d...

Releasing object due to retain count

Hi all, I have an issue with releasing a view too many times. Although simple in theory because im moving uiview to uiview, which is a subclass of uiview and being animated and so on its not something that I can easily fix. It only crashes 10% and only under certain conditions and only 30% of the time even under these conditions. So i...

Can i create my own memory management to handle Cocoa Objects

In C and C++ i use the popular memory pool allocator. Where a huge chunk of memory is allocated and then all small objects are allocated inside it. When done everything is freed with a single call. I was able to speed up some bottlenecks my app by factor 10. Question is how can i do this with Cocoa? How can i overwrite the alloc method...

Memory issues with winforms ImageList

I have an ImageList that is populated with, well you guessed it, images. These images are loaded into memory in a dataset as a Bitmap. Until I loaded them into the ImageList the rise of memory is not worry. But when they are added to the ImageList the memory usage sky rockets. But the biggest problem is when I have to reload the list o...

TextFieldDelegate being deallocated too early

My program is crashing because my TextField is sending messages to its delegate after the delegate has been deallocated. I have an object that serves as a UITableViewDataSource and a UITextFieldDelegate. In cellForRowAtIndexPath, I create a TextField inside each TableViewCell and assign self as the TextField's delegate. When I click a bu...

How to design extremely efficient function

I am designing a function (Java method) which will be executed 40-80 times per second on a mobile device. I want to avoid producing a ton of dead variables which get collected by GC, as the function runs (possibly throughout the life of the app). In C I might use volatile for example, to prevent the memory allocation of my variables ...

NSArray Memory-Management Issue

Hi folks, Here is my code that is being run in a background thread: -(void)updateFAQCache { NSAutoreleasePool *objPool = [[NSAutoreleasePool alloc] init]; // Grab the new plist NSMutableArray *arrLoadedData = [[NSMutableArray alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://myurl.com/"]]; // If the data is ...

Why do I get a leak when using CFPropertyListCreateDeepCopy?

I am creating a deep mutable copy of a dictionary but for some reason am getting a leak. I've tried this: NSMutableDictionary *mutableCopy = (NSMutableDictionary *)CFPropertyListCreateDeepCopy(kCFAllocatorDefault, sectionedDictionaryByFirstLetter, kCFPropertyListMutableContainers); self.copyOfSectionedDictionaryByFirstLetter = mutableCo...

Custom memory allocator/manager in C ? which approach?

I looking for some (custom) memory managers/allocator written in c and went through some articles, - Some Links : IBM - Inside memory management Valgrind - How to Shadow Every Byte of Memory Used by a Program Stack Overflow Question - Write your own memory manager ned Productions - nedmalloc Homepage Two-Level Segregate Fit (TLSF) - W...

NSArray Memory Leak!! Not able to get Why??

Hi I am getting memory leak in Instruments for the following line of code . NSArray *itemsList=[[NSArray alloc] initWithObjects:@"Love", @"Hate",@"Happy",@"Sad", @"Desire",@"Anger",@"Hope",@"Fear",@"Silly",nil]; I am using the below code: arrayList is also released in dealloc block. NSArray *itemsList=[[NSArray alloc] init...

How is retain setter implemented with @synthesize?

I have the following in the header: @property (nonatomic, retain) UIView *overlay; And in the implementation: @synthesize overlay; Then: UIView *tempOverlay = [[UIView alloc] initWithFrame:CGRectMake(160.0f, 70.0f, 150.0f, 310.0f)]; self.overlay = tempOverlay; [tempOverlay release]; Isn't the tempOverlay variable above unnecessa...

Which object pool backing store to choose?

Hello, In our C# (.NET 4.0) application, we allocate and de-allocate a lot of memory, in different size chunks. We want to move to an object pool, to improve performance. We implemented an object pool already and saw some performance improvement. We're currently using a stack-based backing store. Other possible alternatives are, queue ...

C or C++ Heap Memory Management Implementations

Can someone point me to a few open source heap implementations which are not part of a huge library like GLIB. I need one with the following features: Single Threaded The whole heap can be freed with a single call. Small footprint because i need to use one heap for each list/tree widget in my GUI. I think there should be a lot of ex...

Delete pointer to a structure

one of the cpp files has a structure pointer created with "new" operator. Should that pointer be explicitly deleted? Or is the pointer automatically deleted? ...