memory-management

Why would I get a bus error or segmentation fault when calling free() normally?

I have a very simple test program, running on Solaris 5.8: #include <stdio.h> #include <stdlib.h> int main(void) { char *paths; paths = getenv("PATH"); printf("Paths: %s\n", paths); free(paths); // this causes a bus error return 0; } If I don't call free() at the end, it displays the message fine and exits. If I...

Information about PTE's (Page Table Entries) in Windows

In order to find more easily buffer overflows I am changing our custom memory allocator so that it allocates a full 4KB page instead of only the wanted number of bytes. Then I change the page protection and size so that if the caller writes before or after its allocated piece of memory, the application immediately crashes. Problem is t...

java memory management

i have the following code snapshot: public void getResults( String expression, String collection ){ ReferenceList list; Vector <ReferenceList> lists = new <ReferenceList> Vector(); list = invertedIndex.get( 1 )//invertedIndex is class member lists.add(list); } when the method is finished, i supose that the local objects ( list, ...

Running out of memory with UIImage creation on an offscreen Bitmap Context by NSOperation

I have an app with multiple UIView subclasses that acts as pages for a UIScrollView. UIViews are moved back and forth to provide a seamless experience to the user. Since the content of the views is rather slow to draw, it's rendered on a single shared CGBitmapContext guarded by locks by NSOperation subclasses - executed one at once in an...

Does Objective-C 2.0 garbage collection collect C structures?

What exactly does the Objective-C garbage collector collect? For example, if I'm writing a program in Objective-C 2.0, and I use some plain C structs, does my code need to worry about manually freeing that memory? ...

Design: How to declare a specialized memory handler class

On an embedded type system, I have created a Small Object Allocator that piggy backs on top of a standard memory allocation system. This allocator is a Boost::simple_segregated_storage<> class and it does exactly what I need - O(1) alloc/dealloc time on small objects at the cost of a touch of internal fragmentation. My question is how ...

iPhone OS: Strategies for high density image work

I have a project that is coming around the bend this summer that is going to involve, potentially, an extremely high volume of image data for display. We are talking hundreds of 640x480-ish images in a given application session (scaled to a smaller resolution when displayed), and handfuls of very large (1280x1024 or higher) images at a t...

iPhone - Memory Management problems

I am going over my code and trying to get a handle on proper memory management. This code: imageView = [[[UIImageView alloc] initWithImage:myImage] autorelease]; Causes my application to crash. I am using multiple view controllers within a nav bar controller. The app works fine: I can select a person from the first view controller (ta...

Avoiding EXC_BAD_ACCESS when using the delegate pattern

A have a view controller, and it creates a "downloader" object, which has a reference to the view controller (as a delegate). The downloader calls back the view controller if it successfully downloads the item. This works fine as long as you stay on the view, but if you navigate away before the download is complete I get EXC_BAD_ACCESS. ...

How to make Flash 'play well with others'?

What up fam. So this isn't a question asking about memory management schemes; for those of you who may not know, the Flash Virtual Machine relies on garbage collection by using reference counting and mark and sweep (for good coverage of these topics, check out Grant Skinner's article and presentation). And yes, Flash also provides the ...

Memory Leak from Foundation & CFNetwork Library

I am using instruments to resolve memory leak issues for an app in iPhone. I just wanted to know if I have to resolve the leaks coming from Foundation and CFNetwork Libraries. Specifically, the leaks are from: 1. NSCFString 2. NSConcreteData 3. General Block-3584 Since they do not directly point to the code that I have written, how shoul...

Why exactly should I not call free() on variables not allocated by malloc()?

I read somewhere that it is disastrous to use free to get rid of an object not created by calling malloc, is this true? why? ...

release does not free up memory in low-memory condidtion

I am trying to follow the Apple's recommendation to handle low-memory warnings (found in Session 416 of WWDC 2009 videos) by freeing up resources used by freeing up my dataController object (referenced in my app delegate) that contains a large number of strings for read from a plist: - (void)applicationDidReceiveMemoryWarning:(UIApplica...

NSMutableArray for Object which has NSString property causes memory leak

Hello everyone I hope to add objects to a NSMutableArray "myArray", The NSMutableArray is the array for FileObj which has a NSString property "fileName" #import <UIKit/UIKit.h> @interface FileObj : NSObject { NSString *fileName; } -(void) setfileName:(NSString *)s ; -(NSString *) getfileName ; @end // // File.m// #imp...

free() on stack memory

I'm supporting some c code on Solaris, and I've seen something weird at least I think it is: char new_login[64]; ... strcpy(new_login, (char *)login); ... free(new_login); My understanding is that since the variable is a local array the memory comes from the stack and does not need to be freed, and moreover since no malloc/calloc/real...

Possible memory leaks in the Java Development Work

Can any one let me where the memory leaks can happen when we are developing Java based application. I am aware of Database but apart from that, is there any other possible ways . Please list the scenarios ...

Remove pointer object whose reference is mantained in three different lists

I am not sure how to approach this problem: 'Player' class mantains a list of Bullet* objects: class Player { protected: std::list< Bullet* > m_pBullet_list; } When the player fires a Bullet, it is added to this list. Also, inside the constructor of bullet, a reference of the same object is updated in CollisionMgr, where Collisio...

Objective c: How to use memory managment properly for asynchronous methods

I need to call a method that starts some asynchronous code MyClass* myClass = [[MyClass alloc] init]; [myClass startAsynchronousCode]; Now I cant simply release it as this would cause an error since the code is still running: [myClass release]; // causes an error What is the best way to deal with the memory? ...

iPhone: Modal View Controller Leaking Memory

Hi! I'm presenting a modalViewController. After I dismiss the modal view controller with: - (void)dismissModalViewControllerAnimated:(BOOL)animated .. the view is still in memory. How do I dismiss it such that it will use memory? Thanks. ...

iPhone memory management, a newbie question

Hi, I've seen in (Apple) sample code two types of ways of allocation memory, and am not sure I understand the difference and resulting behavior. // FAILS NSMutableArray *anArray = [NSMutableArray array]; [anArray release]; // WORKS NSMutableArray *anArray1 = [[NSMutableArray alloc] init]; [anArray release]; By "FAILS" I mean I get c...