memory-management

Cocoa memory management, why does my app keep using more?

I made a xfire client for mac (called BlackFire -> http://www.macxfire.com) and it keeps using more and more ram over time, even when not doing that much. I have run the app with instruments::leaks and it doesn't show any leaks at all (when it did i fixed them quickly). Somehow it still keeps using more ram, like it is supposed to or so...

Reusing Memory in C++

Just wondering is this kind of code recommended to increase performance? void functionCalledLotsofTimes() { static int *localarray = NULL; //size is a large constant > 10 000 if (localarray == NULL) localarray = new int[size]; //Algorithm goes here } I'm also curious how static variables are implemented by modern c++ c...

Why can I write and read memory when I haven't allocated space?

Hi, I'm trying to build my own Hash Table in C from scratch as an exercise and I'm doing one little step at a time. But I'm having a little issue... I'm declaring the Hash Table structure as pointer so I can initialize it with the size I want and increase it's size whenever the load factor is high. The problem is that I'm creating a t...

Any way to check if an instance is still in memory?

Example: I have a view controller and get rid of it. But there's still an variable holding it's memory address. Accessing that results in EXEC_BAD_ACCESS. Of course. But: Is there any way to check if that variable is still valid? i.e. if it's still pointing to something that exists in memory? ...

Iphone -- Confused about leaks within my NSOperation

My app has an NSOperation class called ServerRequest that handles networking tasks. According to instruments, it is leaking like crazy. Additionally, instruments says the code that builds the request is leaking, even though that is not an NSOperation. But I have followed Apple's advice in terms of setting up an autorelease pool, so I ...

ByteBuffer recycling class

Hi everyone, I'm wonder how I'd code up a ByteBuffer recycling class that can get me a ByteBuffer which is at least as big as the specified length, and which can lock up ByteBuffer objects in use to prevent their use while they are being used by my code. This would prevent re-construction of DirectByteBuffers and such over and over, inst...

How to use an int as an array of ints/bools?

I noticed while making a program that a lot of my int type variables never went above ten. I figure that because an int is 2 bytes at the shortest (1 if you count char), so I should be able to store 4 unsigned ints with a max value of 15 in a short int, and I know I can access each one individually using >> and <<: short unsigned int S...

MATLAB runs out of memory during program execution

I have been happily using MATLAB to solve some project Euler problems. Yesterday, I wrote some code to solve one of these problems (14). When I write code containing long loops I always test the code by running it with short loops. If it runs fine and it does what it's supposed to do I assume this will also be the case when the length of...

Why is my program getting slower and slower ?

I'm using the program to send data from database to the Excel file . It works fine at the beginning and then becomes more and more slowly,finally it run out of the memory and the following error ocurrs: "java.lang.OutOfMemoryError: Java heap space...". The problem can be resolved by adding the jvm heap sapce.But the question is that it...

Stack overflow by presentModelViewController in iphone

Hey I m still facing the problem when I launch my application in iphone. It shows the stack over flow by presentModelViewController bcoz I m using number of viewcontroller and calling the same viewcontroller from other viewcontroller but it gets terminated.Here I m showing the code which I m using in whole program to call other view co...

Why do segments begin on paragraph boundaries?

In real mode segmented memory model, a segment always begins on a paragraph boundary. A paragraph is 16 bytes in size so the segment address is always divisible by 16. What is the reason/benefit of having segments on paragraph boundaries? ...

How do I properly manage memory when using COM objects in VB?

Hi, Can somebody please explain how the memory allocation/de-allocation occurs when we passing values between COM object and VB. My Concerns are: 1. IMyInterface::Method1 ([in] BSTR* pVal, [in] SAFEARRAY(BSTR)* pArray); do we need to free the allocated memory for above parameters inside COM object ? 2. IMyInterface::Method2 ([in, ...

Memory Management Question

Hi, i thought i getting the hang of Cocoa memory management, but apperently i have a lot more to learn. Take a look at this class i wrote: Word.h #import <UIKit/UIKit.h> @interface Word : NSObject { NSString *word; NSMutableArray *wordArray; } @property (nonatomic ,retain) NSString *word; @property (nonatomic ,retain) NSMut...

IPhone programming starter questin with retain/release/object access

Hi there, I'm pretty new in IPhone Development, so maybe you can help me with this problem: I'm having an object "preferences" that holds a single NSString: (All code simplified...) #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> @interface Preferences : NSObject { NSString *username; } -(void)loadPreferences; @propert...

Question about retain count on objects in objects added to arrays, Obj-C

Hi everyone, I'm developing an iPhone app and have a question about memory management. Let's say I have a class called Company with a NSNumber property(nonatomic,retain) called Id. I do this: Company *company = [[Company alloc] initWithId:[NSNumber numberWithInt:1]]; Id should now have a retain count of 1? Then I do: NSMutableArray *...

[C++/C] Segfault when I delete an object - GDB says in free()

I am working on an assignment for networking where we are supposed to create a networking library in C and then use it in our C++ program. My C++ isn't as strong as my C so I got started on that first so I could tackle any problems that came up, and I present you my first one. :D I have a base class and an inherited class (there will ev...

CellForRowAtIndexPath Causing issues, when can I release a local inside there?

Hey all, I have a UITableView that displays various nsstrings from a custom object called a "Transaction." in CellForRowAtIndexPath it the allocates a new instance of a transaction and then copies the the values from a particular transaction that lives in the delegate array so I can access it from different views. It then uses the new ...

Release in viewDidUnload and dealloc both?

I have been under the assumption for a while that viewDidUnload is always called when a controller is deallocated. Is this a correct assumption? I've just been exploring some odd things, and set a breakpoint in my controller's viewDidUnload and it's dealloc. It appears that dealloc is called, but the viewDidUnload method is never call...

CPython - Internally, what is stored on the stack and heap?

In C#, Value Types (eg: int, float, etc) are stored on the stack. Method parameters may also be stored on the stack as well. Most everything else, however, is stored on the heap. This includes Lists, objects, etc. I was wondering, does CPython do the same thing internally? What does it store on the stack, and what does it put on the hea...

Removing Tween For Garbage Collection in AS3

i'm trying to remove a tween object after it has complete so the memory can be freed by garbage collection. in this example i'm passing the fadeIn function a UILoader object that is cast as a sprite so that it fades in when it is finished loading. when the tween finishes animating, i want to remove the tween object. i've included the ...