memory-management

releasing arrays objective-c

In Objective-c I have this: SomeObject *values[3][3]; when deallocating, as in C++ should I release element by element? Or if I do: [values release]; is ok? ...

If my application doesn't use a lot of memory, can I ignore viewDidUnload:?

My iPhone app generally uses under 5MB of living memory and even in the most extreme conditions stays under 8MB. The iPhone 2G has 128MB of RAM and from what I've read an app should only expect to have 20-30MB to use. Given that I never expect to get anywhere near the memory limit, do I need to care about memory warnings and setting ob...

Passing an NSDate

I'm new to the iPhone and objective-c and I am still trying to get my head around ownership of objects so bear with me. I have a DOBViewController that has a datepicker on it. I have created a custom init method: -(id)initWithInitialDate(NSDate *)initialDate; Another view controller has a date instance declared (NSDate *dob) that hol...

JQuery or javascript to find memory usage of page

Is there a way to find out how much memory is being used by a web page, or by my jquery application? Here's my situation: I'm building a data heavy webapp using a jquery frontend and a restful backend that serves data in JSON. The page is loaded once, and then everything happens via ajax. The UI provides users with a way to create m...

java dynamic memory allocation?

Why is an object initialization using the "new" keyword called dynamic memory allocation, since compile time itself we know the memory needed for that object. Also please explain what happens when you do ClassA object = new ClassA(); in heap and stack . ...

returning autorelease NSString still causes memory leaks

I have a simple function that returns an NSString after decoding it. I use it a lot throughout my application, and it appears to create a memory leak (according to "leaks" tool) every time I use it. Leaks tells me the problem is on the line where I alloc the NSString that I am going to return, even though I autorelease it. Here is the...

Memory Profiling with DotTrace Questions

I ran dotTrace on my application (which is having some issues). IntPtr System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr, IntPtr, Int32, IntPtr, IntPtr) Void System.Windows.Forms.UnsafeNativeMethods.WaitMessage() Are the two main functions that came up, taking about 94% of the application time. Since I didn't know what ...

What's the outcome if I use free with new or delete with malloc?

It is a compiler error or runtime error? The code below can be compiled! class Base{ void g(); void h(); }; int main() { Base* p = new Base(); free(p); return 0; } However it can't be compiled with a virtual function if I declare the class Base like this class Base{ virtual void g(); void h(); }; The code below can be co...

Exemple where TYPE_ALIGNMENT() fails

Hi, I have a question relating to alignment in c/c++. In http://stackoverflow.com/questions/364483/determining-the-alignment-of-c-c-structures-in-relation-to-its-members Michael Burr posted this Makro: #define TYPE_ALIGNMENT( t ) offsetof( struct { char x; t test; }, test ) in the comments someone wrote this might fail with non POD ...

Qt: Setup my own QWidget in the right way

In Qt I'm trying to set up my own QWidget so everything should work good due to memory management and other things. But I can't seem to get it all right with pointers, heap and stack. I have my widget MyWidget that have a QList with some objects. I can't figure out how to set up everything right. You can see my code below and I have som...

Should I free a Delphi object auto-instantiated from a web services call?

Newbie question: I have a forms application. It has a separate thread which makes a web services call, and then posts the results of the call to the main form. In my thread, after X seconds have passed (using a TTimer), I call: procedure TPollingThread.OnTimer(Sender: TObject); var SystemProbeValues : TCWProbeValues; begin SystemPr...

Why malloc memory in a function and free it outside is a bad idea?

if this is a bad idea, how to allocate memory in the function? ...

Why is memory management so visible in Java VM?

I'm playing around with writing some simple Spring-based web apps and deploying them to Tomcat. Almost immediately, I run into the need to customize the Tomcat's JVM settings with -XX:MaxPermSize (and -Xmx and -Xms); without this, the server easily runs out of PermGen space. Why is this such an issue for Java VMs compared to other garb...

Finding source of over release

Hi, I'm consistently seeing the same message sent in as a crash report from users of an app. It's clear that an object is being over-released but I'm unable to replicate it and I'm looking for tips on tracing the source of it. The relevant section from the crash report shows this: Application Specific Information: objc_msgSend() selec...

Delphi memory management design strategies : Object or Interface ?

Regarding Delphi memory management, what are your design strategies ? What are the use cases where you prefer to create and release Objects manually ? What are the uses cases where Interfaces, InterfacedObjects, and their reference counting mechanism will be preferred ? Do you have identified some traps or difficulties with reference...

Setting ivar in objective-c from child view in the iPhone

Hi there! Maybe a FAQ at this website. I have a TableViewController that holds a form. In that form I have two fields (each in it's own cell): one to select who paid (single selection), and another to select people expense is paid for (multiple selection). Both fields open a new TableViewController included in an UINavigationControlle...

iPhone objective-c autoreleasing leaking

I do this: NSString *fullpath = [[NSBundle mainBundle] pathForResource:@"text_file" ofType:@"txt"]; Why the following message appear? Is my code leaking? 2010-03-31 13:44:18.649 MJIPhone[2175:207] *** _NSAutoreleaseNoPool(): Object 0x3909ba0 of class NSPathStore2 autoreleased with no pool in place - just leaking Stack: (0x1656bf 0xc8...

DOM memory issue with IE8 (inserting lots of JSON data)

I am developing a small web-utility that displays some data from some database tables. I have the utility running fine on FF, Safari, Chrome..., but the memory management on IE8 is horrendous. The largest JSON request will return information to create around 5,000 or so rows in a table within the browser (3 columns in the table). I'...

Why is a function executed from the same memory address each time?

I'm disassembling an executable: (gdb) disas main Dump of assembler code for function main: 0x004012d0 <main+0>: push %ebp 0x004012d1 <main+1>: mov %esp,%ebp ... Each time the memory address is the same:0x004012d0. Isn't the memory address to be dynamically assigned by the OS? UPDATE Now I see it's virtual space,and it c...

Reallocating memory via "new" in C++

Quick question regarding memory management in C++ If I do the following operation: pointer = new char [strlen(someinput_input)+1]; And then perform it again, with perhaps a different result being returned from strlen(someinput_input). Does this result in memory being left allocated from the previous "new" statement? IE, is each new ...