memory-management

Should I send retain or autorelease before returning objects?

I thought I was doing the right thing here but I get several warnings from the Build and Analyze so now I'm not so sure. My assumption is (a) that an object I get from a function (dateFromComponents: in this case) is already set for autorelease and (b) that what I return from a function should be set for autorelease. Therefore I don't ...

Suggest the best way of initialization of array ( or other objects ) .......

Hi, I am a bit confused in the following two ways of initialisations..... Way 1: - (void) myMethod{ NSArray *myArray = [[NSArray alloc] initWithObjects:obj1,obj1,nil]; [self setClassArray:myArray]; [myArray release]; } Way 2: - (void) myMethod{ NSArray *myArray = [NSArray arrayWithObjects:obj1,obj2,nil]; [self setClas...

Determining Stack Space with Visual Studio

I'm programming in C in Visual Studio 2005. I have a multi-threaded program, but that's not especially important here. How can I determine (approximately) how much stack space my threads use? The technique I was planning to use is setting the stack memory to some predetermined value, say 0xDEADBEEF, running the program for a long time...

Memory profiling for Java desktop application

Hi, My application loads a data set of approx. 85bm to 100mb each time. The application's memory limit is set to 512mb, and this is, theoretically, more than enough. However, I found that if, in a single run of the application, I opened and closed the data set 5 times, the total memory consumption steadily increases, until I get an out...

game is slow first time and then becomes fast

i have new prob when i load application on device first time game is slow and second time when i start new game without closing application it is faster. now its nothing to do with sound coz having same problem with sound off s well. i think its related to sprite. can anyone help i have no time for research ...

Measure a process CPU and RAM usage

Hi, I've found various ways to track down CPU's and RAM's usage from within a process, in C#. I'd like to obtain those infos for an external program (like providing its PID). Is there anything in the .NET framework that can help me? Thanks ...

how do I tell .NET to how much memory it should use? & how much memory it should allocate for a process?

Hello, I'm aware that .NET doesn't use complete physical memory availabe. I've encountered a System.OutOfMemoryException while the physical memory usage as only 79%. I've run my system until 92% of physical memory usage. You can see screenshot here: http://a.imagehost.org/0655/CaptureOOM.gif How do I tell .NET to use more memory? I...

How to release or nil a type-casted object?

I am a bit confused about the objects which are initialized by type-casting. Like UITextField *txtFld = (UITextField *)[self.view viewWithTag:someTag]; // // //some code here for this text field usage // // now when I am finished using this text field should I set it to nil or leave it as it is for the system to take care of it. Now ...

Why should we release ?

Hi all, I often see when we release ab object we immediately set it to nil. I know that release and nil both free the old value associated with object but in case of release it leaves the object as a dangling pointer so we have to set it to nil. So my question is if nil frees the old value of the object and set the object to nil why sh...

C++, Can't use an array or vectors, how do I use a pointer to get through this mess?

I need help with pointers and memory management. I need to store different objects, all derived from the same base class, and have been using an array to do this but it is causing a segmentation fault when the array is populated with different objects. My program works fine when the array is full of objects of the same derived type. ...

Tableviecells are not getting deallocted.....Memory Management issues.

hi... I am working on an application in which uitableviewcells of uitableview are customized which contains a textfied(contains managedobject/core data), label((contains managedobject), buttons so all are customized. i am creating uitableview dynamically using sqlite. Similarly uitableview view contains more than 15 cells. Cells are d...

A problem with release object

here my code - (UIImageView *)createImageView:(NSUInteger)inImageIndex { UIImageView * result = [[UIImageView alloc] initWithImage:[mImages objectAtIndex:inImageIndex]]; result.opaque = YES; result.userInteractionEnabled = NO; result.backgroundColor = [UIColor blackColor]; result.contentMode = UIViewContentModeSca...

Are viewDidUnload and dealloc always called when tearing down a UIViewController?

I have a query about the use of viewDidUnload and dealloc in a simple implementation of UITableViewController. Essentially I'd like to know more about weather or not both viewDidUnload and dealloc are always called in succession in the tear down process. Is it possible that dealloc could be called on the controller without viewDidUnloa...

Why is this object being deallocated?

Hi, I'm developing an iPhone app, I'm trying to push a view into the navigation controller, which I've done many times before, however, I'm having some issues with this particular app. I have a table view, and when the user selects one row the new view is pushed into the controller: DataWrapper *row=[[self.rows objectAtIndex:[indexPath ...

Memory usage accounting in a navigation controller-based app;

I have a navigation controller-based application that could be active for a relatively long time and can load multiple screens, revisiting some in the course of its life - a business application. When I push a screen I allocate some memory; when I go back (pop it) I need to ensure memory is not lost. Now in Leaks I have a clean slate. N...

Are multiple UIView animation callbacks a bad idea (i.e. cause mem issues)?

I have multiple UIView animations running in my app. They are very short, and then make callbacks to a method that then usually fires off another animation. This leads to a lot of little animations running at the same time, each firing back callbacks. This actually performs pretty well, and for the first few levels (the app is a game)...

C# .. Asynchronous Sockets .. where is the State Object Stored?

Hi all, A simple question really, but one where I cannot find any anwsers too. When I execute an Asynchronous Socket operation, such as : socket.BeginSend ( new byte[]{6}, // byte[] | buffer 0, // int | data to send buffer offset 1, // in...

Comparing java memory heap dumps: Memory profiling for Java desktop application

Hi, This is a more specific question to follow up on another question that I have asked recently. A correct answer for this question will earn a correct answer for that previous question too (since that is still in limbo)! Basically I have a Java desktop application with a memory leak issue. I am using the memory profiler in Netbeans I...

Core Data Malloc Errors

Hi there, I've noticed I'm getting a few errors at random points in my app. I've had 2 errors, "double free" and "incorrect checksum for freed object". Heres the stack trace of a "double free" error. Can anyone provide any insight? It's happening on a call in my code that just sets an attribute to an NSNumber so I can't understand why i...

How do I release this CGPath when I need to return it

I have a method that returns a CGMutablePathRef, something like this: - (CGMutablePathRef)somePath; { CGMutablePathRef theLine = CGPathCreateMutable(); CGPathMoveToPoint(theLine, NULL, 50, 50); CGPathAddLineToPoint(theLine, NULL, 160, 480); CGPathAddLineToPoint(theLine, NULL, 270, 50); return theLine; } The Xcode/Cla...