memory-management

Automatic pointer for Symbian

Is there any kind of automatic pointer, similar to auto_ptr or scoped_ptr, for Symbian? ...

How to print or know the values in autorelease pool?

Hi, I have a large set of code and i need to test them with memory management concepts. Can i know how to print or know what are the objects a particular pool contains? Please help me? ...

Adding subview then releasing it: "modifying view that is being finalized"

I've got a UIButton called tagButton and a UIScrollView called tagsView. Inside my -(void)renderTags method, I do [[self.tagsView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)]; ...to clear the decks, then I walk through a pair of arrays called allTags and activeTags, alternately creating "lit" and "unlit" butto...

Objective C Memory Management Woes

I know this has been discussed ad-nauseum but I just don't get some of the memory management. I understand that retain keeps the object alive and copy gives one a separate copy of an object. What I don't get is when it comes to ivars & properties, retain as a property means that the setter releases the old value & retains the new: prop...

Instruments says I have a memory leak, but I don't see it

I have a method to generate a Deck object (NSObject subclass with an NSMutableArray property) and it populates the array with Card objects (UIView subclass with some integer and one NSString property). When I ask for a Deck I check to see if one already exists (I think) and if so, release it before getting a new one. The code from my v...

In what situations Static Allocation fares better than Dynamic Allocation?

I was going through some of the decisions made to make Xara Xtreme, an open source SVG graphics application. Their memory management decision was quite intriguing to me since I naively took it for granted that on-demand dynamic allocation as the way of writing object oriented application. The explanation from the documentation is ...

Memory deallocation in c++ issue (Visual Studio 2010)

Hi, I am trying to learn C++, in the process I tried to write a function that gets two char pointers and concatenate the second one to the first one (I know there is strcat for this). But - what I want to accomplish is to modify the first parameter pointer so it will point to the result. for this reason I used a reference to pointer in t...

Why can't OS use entire 64-bits for addressing? Why only the 48-bits?

I'm reading "Understanding Linux Kernel". Paging for 64-bit Architectures As we have seen in the previous sections, two-level paging is commonly used by 32-bit microprocessors. Two-level paging, however, is not suitable for computers that adopt a 64-bit architecture. Let's use a thought experiment to explain why: ...

How Retain cycles occurs in Memory Management?

Can some explain the retain cycles problem with a sample program? ...

Where to release an object? dealloc or ViewDidUNload

Hi Friends, When we need to release an object,where to do it, either at the dealloc method or in the ViewDidUnload for a viewController? which would be better? I think that viewDidUnload would do better, because once the view controller is unloaded the objects would be released. And in the dealloc case, from the documentation When...

Calling property's setter method with nil value

Hi Friends, Consider I have a property named sampleObject. In dealloc method, which should be the best way to manage memory? Option 1: self.sampleObject = nil; //This will release the sampleObject and set it to nil This is equivalent to [sampleObject release]; sampleObject = nil; Option 2: Explicitly releasing an object and ...

Is object free / freed on dealloc and / or release?

I recently took an objective-c test to see how I would do. Turns out my score wasn't anywhere near as good as I hoped. That means more studying. During the test, I was asked this question: How do you free an object? A. [obj dealloc]; B. [obj release]; C. None of the above My choice was A, and I don't know if it's correct. The ques...

C++: How to know if a pointer points to the heap or the stack?

The title says it all. Example: bool isHeapPtr(void* ptr) { //... } int iStack = 35; int *ptrStack = &iStack; bool isHeapPointer1 = isHeapPtr(ptrStack); // Should be false bool isHeapPointer2 = isHeapPtr(new int(5)); // Should be true /* I know... it is a memory leak */ Why, I want to know this: If I have in a class a member-p...

iPhone dev - objc_msgSend with no specific line number

When I usually get runtime errors I can open up the Debugger view in XCode and see what line it occurs and fix accordingly. What do I do when there is no line number? I must have an allocation/deallocation memory error somewhere, but how do I go about finding it? The instruments tool is virtually unuseable and slow - sometimes not loadin...

Core Data memory management

Just want to make sure I'm doing right things with memory management of Core Data. In my view controller's (which is tab bar view) viewDidLoad I use NSFetchRequest to retrieve the rows I need. Then I retain returned NSArray object, since I need to wait for user interaction to show the part of this data. In viewDidUnload I release that a...

Why am I getting this java.io.exception "Can't allocate memory" from Hudson?

Here's what I believe to be the relevant error message: Caused by: java.io.IOException: Cannot run program "/usr/bin/git" (in directory "/var/lib/hudson/jobs/Goals/workspace"): java.io.IOException: error=12, Cannot allocate memory at java.lang.ProcessBuilder.start(ProcessBuilder.java:474) at hudson.Proc$LocalProc.<init>(Proc.jav...

Populating an NSArray/NSMutableArray, the right way

This is a general question about memory management and best practices when using Cocoa arrays. Which of the following is "better": NSArray *pageControllers = [[NSArray alloc] initWithObjects: [[Page1 alloc] initWithNibName:@"Page1" bundle:nil], [[Page2 alloc] initWithNibName:@"Page2" bundle:nil], [[Page3 alloc] initWithNibN...

Don't understand memory analysis

Hi, I have upgraded my XCode to versio 3.2.3 to support iOS4 on my iphone project. using the static analyser I checked for memory management problems. In one of my routines I get the following problem: I generate a user alert after adding an event to the calendar to give him a status. This runs fine, but the memory analyser doesn't li...

Difference between physical addressing and virtual addressing concept.

hi, This is re submission , because am not getting any response from superuser.com Also sorry for the mis understanding. First of all I need to know , difference between physical addressing and virtual addressing concept in an embedded systems? then why virtual addressing concept is implemented in an embedded systems ? then what is t...

What is the difference between shared data and user data desciptors ?

hi, While referring some MMU configuration files(one freescale sc140 arch) , i have seen some definition fields for User data and shared data descriptors? Can anybody give me some inputs on the two words? /renjith_g ...