memory-management

Newbie IPhone developer using Instruments panel: Where is my leak?

Update I have update the planets.m/h files to reflect the suggestions made by the commentors (thank you bbum and DarkDust. my factory methods now all call autorelease and look like this: - (Planet *) initWithName: (NSString *)name; + (Planet *) planetWithNameAndMoons:(NSString *)name moons:(id)firstObj, ... NS_REQUIRES_NIL_TERMINATI...

Disposing objects added using AddValue of SerializationInfo

How can I make sure that the objects get disposed that I am adding into the SerializationInfo object? For example: if I am adding a hashtable to the info object, how do I make sure that after serialization, there is no reference alive to the hastable object of my class and I can free the memory somehow? info.AddValue("attributesHash", ...

Static Array Inside Class Causing Memory Issues? What Other Options Are There?

Good morning SO, I have a class that contains the following static array: public static ResultObject[] ResultArray = new ResultObject[500]; In my program, there are 12million instances of this class that all add to this array. I'm getting a OutOfMemoryException and think this might be the reason why. Is there any way I can manage...

Are Generic lists stored on the stack or the heap in C#?

Are Generic lists stored on the stack Or the heap? example //List of Ints List<int> myInts = new List<int>(); myInts.Add(5); myInts.Add(10); myInts.Add(20); Is myInts stored on the stack or the heap? If I add an int to the list, does boxing or unboxing occur? ...

does copy/mutableCopy operation increment retain count value ?? (Objective C)

does copy/mutableCopy operation increment retain count value ?? (Objective C) ...

iPhone - Memory management question ???

Let's say i have a navigation controller in my app delegate. Why is it necessary to release it on dealloc method in my appDelegate? When the dealloc method of my appDelegate is called, it means user is exiting the app, so the leak doesn't affect my application. So why would i release anything in dealloc method of my appDelegate? ...

Accessing property inside non-init methods gives bad access...

Hello, I've begun work on a side project, so the codebase is very small, very little that could go wrong. Something strange is happening. In viewDidLoad I initialise an array set as a property: @property (nonatomic, retain) NSMutableArray * story_array; And fill it with data. This printout is fine: NSLog(@"%@", ((ArticlePreview *)[s...

Released object crashes App -- problem with alloc/init memory management

I have a flipView class that I allocate and initiate. But, when I release it the app crashes. If I don't release it, the app works fine, so it seems. The error message I receive when I release it is: Malloc - error for object: object pointer being freed was not allocated. If you could please assist me, I would be grateful. - (IBA...

Lazy Loading in Objective-C - which is more correct?

This is a small detail but everytime I lazy load something I get caught up on it. Are both of these methods acceptable? Is either better? Assume that the variable has the retain property. Method #1 (AnObject *)theObject{ if (theObject == nil){ theObject = [[AnObject createAnAutoreleasedObject] retain]; } return theO...

No memory leaks, yet still running out of memory?

In my cocos2d application I have run through it using instruments and removed all memory leaks. I have my game outputting how much memory is in use on the screen and it is constantly rising as the game progresses until I eventually run out of memory. The amount of objects on screen doesn't increase by very much each level. Its a fairly s...

How to go from String to Data.ByteString.Lazy in an existing Haskell code ?

Hi, I have a Haskell code which use a lot of String, while profilling it, it appear that the code use a lot of memory to store Lists []. One solution to this problem is to use Data.ByteString.Lazy instead of String, but what I have to care about while doing this ?, which part of the code have to be look carefully : fold, map, ... ? ...

big memory needs

recentry we had task to need big amount of memory (RAM) but have hot enought... but we have much free HDD space maybe exists tools (linux) which can handle process memory request (etc) and have limit RAM swap it into HDD (like 'nice' tool handle priority)? ...

Severe multi-threaded memory bottleneck after reaching a specific number of cores

We are testing our software for the first time on a machine with > 12 cores for scalability and we are encountering a nasty drop in performance after the 12th thread is added. After spending a couple days on this, we are stumped regarding what to try next. The test system is a dual Opteron 6174 (2x12 cores) with 16 GB of memory, Windows...

Objective C - Memory management question ??

I know that when i have a property for an object which is set to retain or copy i must do the following. Object *o = [[Object alloc] init]; self.myObject = o; [o release]; but what if i don't define a property for myObject? Can i do the following without having a leak? Is it better to define a property for every variable I have in e...

Random malloc crashes in stringByReplacingOccurrencesOfString

Hi, I am getting random malloc crashes in stringByReplacingOccurrencesOfString. I've noticed that it crashes on longer strings, but I can't seem to find why. What could be the problem? The error: CashTrader(53448,0xb0103000) malloc: *** error for object 0x5c5eca0: incorrect checksum for freed object - object was probably modified afte...

OpenCl cleanup causes segfault.

Hello! I constructed my own little Opencl example using different sources on the net. The actual kernel works, and I get the output I want, but the cleanup functions, I found in one of the examples, cause segfaults. What did I do wrong? #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <CL/cl.h> //opencl #define CL_CH...

Objective-C Mutlithreading and Data Containers

Hey guys, I have sort of a simple question. I am writing an Objective-C program with some multithreading. I have a global NSArray, and I add objects into that NSArray from a method that is called in a new thread. If the objects I add into that NSArray are new objects created in that method (local), will that create memory access and/or ...

Memory management about CGPoint

refer to http://stackoverflow.com/questions/1746378/cgpointmake-explaination-needed Correct me if I am wrong, in the implementation of CGPointMake, CGPoint p; declare a local variable of a struct, which should should be freed after leaving the scope. But why the function can return the value without risk? Anyway, assume that implementa...

Memory requirements of an Object reference on a 64 bit JVM

A reference to an Object on a 32 bit JVM (at least on Hotspot) takes up 4 bytes. Does the 64 bit Hotspot JVM need 8 bytes? Or is some clever compression going on? If not, every Object[] would require twice as much heap memory, which I somehow think (hope, expect) is not the case. Update/extra question: Does this really matter, or is th...

UIViewController Memory Management/Issue?

Hi, I have noticed a strange behavior when adding and removing UIViewControllers I dont post for now any example,I have some view controllers that load their view from a xib and others that i create the view manually.(Do i have to declare Outlets for every element created in IB?even those that are static graphics?or does deallotion happe...