memory-management

Tips for finding and debugging abandoned memory and heap growth

I recently watched one of the WWDC 2010 videos: Session 311 - Advanced Memory Analysis with Instruments. The link is here. There is an interesting example in the video on finding Abandoned Memory. They say that it is often more important to debug than leaks but can be more difficult. Abandoned Memory is defined as "Accessible allocate...

Profile Memory useage for my Windows Mobile Application

Is there a tool that allows me to profile the memory usage for my Windows Mobile Application. My app has a section of code that is right up against the limit of the total memory. I have tried to setup my code so that the references to large objects go out of scope before new references are needed. But I need a way to see if it is work...

Autorelease object returned from NSArray?

I'm writing an NSArray category to include the -objectAtRandom message that returns an object from a random index (something similar to Python's choice). Should I autorelease this object before returning it? I believe I shouldn't, but I'm not sure... ...

What to do when my app receives memory warning?

What should I do when my app recieves a memory warning? ...

What's the trade off for the smaller stack boundary?

In gcc 4.5 the stack must be aligned to a 16-byte boundary when calling a function (previous versions only required a 4-byte alignment). 4-byte is reasonable for 32-bit machine. 16-byte is easy to align by just "and 0xfffffff0, %esp". But it might cost much more memory than 4-byte boundary, doesn't it? In short, My question is why gcc ...

Using/Mixing C in C++ code?

Is using C in C++ bad? Many people have told me that using C in C++ is bad because it's not as safe, and it requires more memory management. I keep telling them that as long as you know what your doing, and you delete your new's and free your malloc's then C isn't a problem. I'm currently on a forum where an argument over std::string v...

Memory Management: Is insertSubview retaining it's views?

The question is if insertSubview is retaining the views and if I'm doing it right. I would say yes. Since I'm not using the property anymore I don't receive an EXC_BAD_ACCESS. I think when releasing the view all subviews are also released. And so mapView is over-released. I'm right or do I still have a memory management issue? My ViewC...

releasing subcontrollers

Im making a gallery and using a scrollview to show fullscreen size images, after som images i recive a memory warning, right now i didrecivememorywaring ` - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; for (unsigned i = 0; i < [appDelegate.inGallery count]; i++) { if (i != currentPage && i != currentPage ...

C# calling C++ method that returns a pointer. Explain memory management.

Can someone explain what exactly is happening at a low level / memory management perspective on the 2 C# lines in "Main" in the following? C++ Code (unmanaged): #define DLLEXPORT extern "C" __declspec(dllexport) DLLEXPORT MyClass* MyClass_MyClass() { return new MyClass(); } DLLEXPORT void MyClass_setName(My...

Dll Memory Management

I have few doubts regarding how windows manages a .dll's memory. when .dll's are loaded into the host process, how is the memory managed? Does .dll get access to the entire memory available to the host process or just a portion of it? i.e is there a limitation when memory is allocated by a function inside the .dll? Will STL classes li...

Development time

Hi, Usually if there is a development task that takes 4 days, if you put 2 developers on it then it does not necessarily halve the overall development time i.e. instead of 2 days it will take a bit more than 2 days due to things like developer discussions, technical meetings, disagreements, dependencies etc. What is the "technical term"...

Is return @"Text"; autoreleased?

I wonder if return @"Text"; is autoreleased? And if it is so could you please explain it. Is the compiler creating a NSString object for us or how will the compiler handle this? ...

Custom Unique_ptr deleter, controlled deleting

I have a for loop that iterates through an XML document and finds a specified attribute, the pointer that points to the current node sits inside a boost::interprocess::unique_ptr and has a custom deletor to call the object's release() function. It seems that on every loop iteration the pointer gets deleted, but the release() function th...

Free() returned char pointer doesn't remove it from memory?

Basically the problem comes down to this: I load a file, write all the each character into a char* variable which has malloc() the length of the file. Then I return that variable and print it, then I free() the memory for that variable and try to print the variable again which does print it. I'm very new to C so there is probably som...

does cvrelease delete the allocated memory?

Hello. This might be the wrong way of doing things, but I pass an array from LabView into my C++ function as a simple array of char. I then create an OpenCV image and point the pointer to my data that was passed. At the end of the function I use cvReleaseImage to delete all the OpenCV images, would that remove the data off my original p...

iphone - question about over-releasing

In any iphone template UIViewController class you will see this: - (void)viewDidUnload { // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } But if I set self.myOutlet = nil in viewDidUnload, and I also have [self.myOutlet release] in the dealloc method, isn't that over-releasing self.myOutlet, s...

Why retainCount returns value after release being called?

Hello, I have the following simple piece of code: NSMutableArray *array = [[NSMutableArray alloc] init]; NSObject *o = [[NSObject alloc] init]; NSObject *o1 = [[NSObject alloc] init]; NSObject *o2 = [[NSObject alloc] init]; [array addObject:o]; [array addObject:o1]; [array addObject:o2]; NSLog(@"-------");...

Optimize loading of many images on iPad

I'm working on a project for the iPad where I'm trying to simulate the rotation of a 3D-body with touch by switching pre-rendered images. I'm not the sharpest man when it comes to memory management so I wonder if anyone has any tips on how to optimize this. My solution now looks something like this: - (void)touchesMoved:(NSSet *)touch...

Memory management: manual retain/release or accessor methods?

What is the best approach in terms of: security and control of leaks? performance? visibility outer the class? First: keeping control of each variable if (objectProperty_ != anObject) { [objectProperty_ release]; objectProperty_ = [anObject retain]; } Second: declaring properties and using the accessors and letting the sys...

MemoryInfo on ZTE Blade(Android), not working

Have been trying to find out memory usage on the android applications on the phone. Just for fun and testing. But when using the code snippet from here http://stackoverflow.com/questions/2298208/how-to-discover-memory-usage-of-my-application-in-android/3479710#3479710 I'm getting zero on pidMemoryInfo.getTotalPrivateDirty() pidMemoryI...