memory-management

Is there a limit for the total variables size on the stack?

While coding should we consider some limit on the total size of variables created on the stack? If yes, on what basis should we decide it? Is it dependent on OS, Memory Availability etc? Are there any compiler options which can check this? Any pointers in the direction will also be helpful. ...

Why is PermGen space growing?

I've read a few articles, and I understood the following (please correct me and/or edit the question if I'm wrong): The java heap is segmented like this: Young Generation: objects that are created go here, this part is frequently and inexpensively garbage collected Old Generation: objects that survive the garbage collections of the Y...

How do I free memory obtained by sbrk() ?

I have a custom allocator function which uses sbrk() to obtain memory. How do I release this memory when it's no longer needed? Is there a function equivalent to free() for malloc() ? or do I have to use brk() to set the end of the data segment ? ...

Objective C/iPhone : need "best practices" for debugging memory management bugs

So... I've written my first iPhone game, that consists of maybe 50 puzzles. At the start of each puzzle I create some strings, various mutable arrays of pointers, some of which point to runtime created subviews. All retained variables are declared as various class properties. Then at the end of the puzzle I remove the subviews, release...

Python Identity Problem: Multiple Personality Disorder. Need Code Shrink

I stumbled upon the following python weirdity: >>> two = 2 >>> ii = 2 >>> id(two) == id(ii) True >>> [id(i) for i in [42,42,42,42]] [10084276, 10084276, 10084276, 10084276] >>> help(id) Help on built-in function id in module __builtin__: id(...) id(object) -> integer Return the identity of an object. This is guaranteed to b...

Objective-C memory not being freed with large arrays...

Hello all, I am developing a program in Cocoa, with the hopes of using the smallest amount of memory possible. To check this, I have been using Activity Monitor. My program has a fairly large NSMutableArray containing instances of NSString, and when I release the array, I do not get all of my memory back. The following example demon...

What is a good resource to read about stack/heap and symbol table concepts?

Please suggest some website or some book that deals with these topics in really good detail. I need to have a better understanding of these concepts (in reference to C++): stack and heaps symbol tables implementation of scope rules implementation of function calls ...

Dynamicly added subview disappears

I have a UIView that gets created and added as a subview dynamically, not in interface builder. Problem is the subview disappears eventually and all that is left on the screen is the objects that are defined in the xib that is being loaded. It seems to occur once the retainCount of the subview drops from 3 to 2. I'm fairly new to iPhon...

Avoid memory fragmentation when allocating lots of arrays in Java

I am developing an application in Java that runs on Windows Mobile devices. In order to achieve this we have been using the Esmertec JBed JVM, which is not perfect but we are stuck with it for now. Recently we have been getting complaints from customers about OutOfMemoryErrors. After a lot of playing around with things I discovered th...

Object Oriented Programming

I have confusion about the concept of inheritance in C++, suppose we have a class named computer and we publicly inherit a class named laptop from computer class. Now when we create an object of class laptop in main function what happens in the memory? Please Explain. ...

Are there any good software development "patterns" for memory intensive .net programs?

Basically I'm working on a program that processes a lot of large video and image files, and I'm struggling with the memory management side of it because I've never dealt with anything quite like this before. For instance, it stores all these images in a database, and loads a list of videos, and then you can switch between the videos an...

UITextField - [textField becomesFirstResponder] - remember text

NSString *tmpTxt = textField.text; BOOL result = [textField becomeFirstResponder]; textField.text = tmpTxt; This works 80% of the time, but occasionally: The whole app will crash. The text will still be deleted whatever happens. Whats the best way for a textField to becomeFirstResponder and still retain its text value. ...

iPhone - Program Received Signal : 0 - on device but not on simulator

Hi, I'm sure this is memory related but I can't seem to figure out what variable is causing me problems. I'm releasing everything I allocate as far as I can tell. This loop seems to work fine if it runs 365 times but not 730 (its doing days in a year). Here is the snippet of code that is failing.. it never gets out of the loop when th...

iPhone Memory Management

Hi all, I'm working on an app and I'd like to make sure that I'm managing memory properly and releasing everything that I should. In my viewDidLoad method I allocate some variables in determining which background to apply to the view (for internationalization) and the app works fine if I don't release them. The problem is that if I re...

iphone app NSNumber memory leak

Hi, I'm having a memory leak and I have no clue where it comes from and how to fix it. At some point i calculate the distance between 2 locations. double calc = [self getDistance:location to:otherLocation]; NSNumber *distance = [NSNumber numberWithDouble:calc]; in instruments i get as leaked object NSCFNumber and it identifies NSN...

Can I use the C++ Boost shared_ptr to program as if I was coding in Java, as in, not care about memory management?

It's been a while I coded in C/C++, and now I need its efficiency for a project I'm doing. What I understand from this shared_ptr is that it basically deletes the object when I need it to. So, if, for example, my object has a vector of shared_ptr, I wouldn't have to worry about iterating through the vector and deleting each element in t...

Stack based memory allocation

With reference to Stack Based Memory Allocation, it is stated as "...each thread has a reserved region of memory referred to as its stack. When a function executes, it may add some of its state data to the top of the stack; when the function exits it is responsible for removing that data from the stack" and "...that memory on the stack i...

my C program has a char, and I want it to hold more data, what data type do I substitute for it?

I want to modify a program that grabs images from a camera capture board, now its using a char and says its limited to 1000 images, its early/late and I need sleep, so maybe there is a better way to go about this, but I am thinking maybe I could just substitute all the related data variables with higher capacity data types... right now i...

iPhone memory leak help

This code is leaking, the performance tool blames two leaks on this block of code. If i comment it out the leak doesn't happen. Any help pinning it down would be greatly appreciated. Leaks: Malloc 48 bytes NSCFarray 32 bytes Code Block: NSArray *myArray = [[NSArray alloc] initWithObjects: @"Add", @"Edit", nil]; segmentContro...

image caches (sqlite)

hi there i'm new to iPhone dev so plz be gentle ... i've created an iphone app which uses CoreData sqlite DB i've very more than 50 pic with huge size in my DB when i display an image it won't be deleted from memory when i get out from the view (cache) -(void)loadView{ [super loadView]; self.title = @"Photo"; imageScrollVi...