memory-management

About integers and memory management in Objective-C

I have this code in one of my projects (part of a loop): newPath = [tileMap updatePathFromNode:point1 toNode:point2]; int x,y; x = [[newPath objectAtIndex:0] nodeX]; y = [[newPath objectAtIndex:0] nodeY]; currFiend.motionTarget = ccp(x*20,y*20); I am now looking for areas around my entire project to optimize the code. What i'm curiou...

SQLite + memory management issues

I have a SQLite database containing image data as a BLOB, and I am using the follow code to set the properties of an object, but I am getting major memory issues with the data, particularly on the data and w.wineImage objects, even though it looks like I am releasing everything correctly... if(sqlite3_prepare_v2(database, sql, -1, &sele...

Code is extremely leaky.. I need help Identifying where the leaks are coming from.

My code works fine on my ipod, it's not slow and doesn't crash, but using Instruments I discovered 826 leaked blocks. The Header file is: #import "CountySelectionViewController.h" #import "iProspectLiteAnnotation.h" #import "iProspectLiteAnnotationView.h" #import <CoreLocation/CoreLocation.h> #import <iAd/iAd.h> #import <sqlite3.h> #imp...

Simply open and close dialog winform will increase memory usage

I am trying to reduce memory usage of a winForm application. There is a main form and a setting form in the application. When "Setting" button been pressed, the setting form will popup as a modal form, the Setting form will load app.config data from config file and read them to memory as Hashtable. After the setting form closed, it will...

Core Data: avoiding retain cycles in to-many relationships

I'm still learning my way through iOS development and working with Core Data and have just come across retain cycles. It is my understanding from reading the Core Data Programming Guide that after you're done working with a relationship, you use the managed object context method refreshObject:mergeChanges to ensure that the retain cycle...

How to use Delphi Dlls without enabling Build with runtime packages

Recently i started a project with so many forms , frames and extra controls, so my application was swelling up and i am using 3 exes in my projects(all made in Delphi 2009) and these applications are also sharing same frames and forms. so i used dlls to share these forms. but a problem came saying different Tfont error. so i refferd on...

IPhone memory management

I am a bit lost with the memory management. I've read that you should release whenever you alloc. But when you get an instance without the alloc, you shouldnt release. What about this situation, just need to know If I was coding correctly. I'm still new on iphone dev. I have a class CustomerRepository it has a method - (MSMutableArr...

Memory Management and Exception Handling

Hello, I have a simple class that handles the connection being made between a client and server. To let more than one user communicate with the server at one time each new Client connection is made on a separate thread. In this class I create two streams that act as the inbound and outbound streams for the client. I create the fields ...

Passing objects into NSOperation and ensuring correct memory management policies

If I want to pass an object that was created on the main thread onto an NSOperation object, what's the standard way of doing to so that I'm not creating any memory management issues? Should I make my object's properties not have the 'nonatomic' attribute? Right now, I allocate the objects via [[[AClass alloc] init] autorelease], keep a ...

MemoryError hook in Python?

Is there a way to globally trap MemoryError exceptions so that a library can clear out caches instead of letting a MemoryError be seen by user code? I'm developing a memory caching library in Python that stores very large objects, to the point where it's common for users to want to use all available RAM to simplify their scripts and/or ...

didReceiveMemoryWarning - manually unload views?

There are times when didReceiveMemoryWarning gets called, but viewDidUnload does not. In my situation I would like to force viewDidUnload when didReceiveMemoryWarning gets called. I can say this: [self viewDidUnload]; But will that really unload the views? There is no self "unloadView". ...

IPhone Repository for data

I'm a totally noob in IPhone development. Just start a week ago. I'm trying to have this tableview working. I have a class I created called CustomerRepository with a method like this - (CustomerRepository *) init { self = [super init]; if (self) { customerArray = [[NSMutableArray alloc] init]; Customer *cust1 = [[Custome...

Cocoa Touch retain object returned from NSUserDefaults?

I have a NSArray object retrieved from the standard user defaults object, [NSUSerDefaults standardUserDefaults]. I want to save this array as a member variable of another object and use it for the lifetime of this object. I'm not sure if the array from NSUserDefaults is an autorelease object. Should I retain the array? ...

Implementing NSCopy

I'm a little confused on the correct way to make my class support NSCopy mechanics and I'm hoping someone can help clear things up for me. The big question is this: If my class is mostly immutatble except for a collections property, when I'm implementing the 'copyWithZone' method through NSCopy inheritance, do I need to do the version w...

Yield and freeing Memory

I have WCF web service that I use to send images from my Windows Mobile client app to my server. When I try to send the images I can't load all of them from my database at the same time or I will get an out of memory exception. So I am thinking I will call my web service with batches of 10 or so. What I want to know is, if I set up an...

Making deep copy of UIImage

My class contains an UIImage property which I want to enforce as a 'copy' property by any external clients accessing it. But, when I try to do a copy in my custom setter, I get the runtime error about UIImage not supporting copyWithZone. So what's a good way to ensure that the correct ownership policy is followed? // declared in the int...

What is faster and more convenient: Hashtable or Dictionary<int, double>()?

Preamble: I'm working at heavy-loaded applicaion that produces large data arrays. I wrote the following class using System; using System.Collections; using System.Collections.Generic; namespace CSharpSampleApplication.Data.CoreObjects { [Serializable] public class CalcItem { pub...

IPhone NSMutableArray memory management

Being a noob in Iphone dev, just trying to understand. In the code below, what is happening exaclty? City *newCity = [[City alloc] init]; newCity.name = @"name"; NSMutableArray *array = [[NSMutableArray alloc] init]; [array addObject:newCity]; City *getCity = [array objectAtIndex:0]; [city release]; [array release]; when you add ...

how to resolve segment:offset adres in GDB

(gdb) info registers ds ds 0x7b 123 (gdb) disassemble Dump of assembler code for function printf@plt: 0x0804831c <+0>: jmp DWORD PTR ds:0x804a008 => 0x08048322 <+6>: push 0x10 0x08048327 <+11>: jmp 0x80482ec End of assembler dump. Can someone describe me how to map ds:0x804a008 address into linear ad...

placement new + array +alignment

SomeObj<unsigned int>* Buffer; char* BufferPtr = MemoryManager::giveMeSomeBytes(resX*resY*sizeof(SomeObj<unsigned int>)); Buffer = new(BufferPtr) SomeObj<unsigned int>[resX*resY]; when I step past these lines with the debugger, it shows me the values for the variables Buffer and BufferPtr: BufferPtr: 0x0d7f004c Buffer: 0x0d7f0050 ...