memory-management

NSPredicate Memory Issues

So I am trying to fix this really annoying bug. If I filter my array like the ideal version with NSPredicate, I will get EXC_BAD_ACCESS because it tries to call release on the object passed in as the delegate an extra time. If I filter with the working version, it works fine. I thought these two implementations were identical. Where am I...

Does exiting from a pthread release malloced memory ?

Let's say I pthread_create and then pthread_detach it. Now, from within the thread function, I malloc some block. When the thread exits, will the malloc'ed memory be freed automatically? (been googling for an answer to no avail...) ...

Objective-C member initializiation of autoreleased objects

Hey so if I have some property like @interface MyClass { NSArray* myArray; } @end @property (retain, nonatomic) NSArray* myArray; In my init method should I do something like myArray = [[NSArray array] retain]; Or self.myArray = [NSArray array]; I would think the former would be preferred as it is more clear what is going on...

What should be the reason behind this leaky line ?

I have follwowing peace of code in which I have specified the leaky line . As I am new to iPhone developement I can't understand what actually is wrong with that line . please have a look at that line and tell me . NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init]; //take away //NSURL *url1 = [[NSURL alloc] initWithStrin...

Dynamic Memory Allocation in C++

What is the difference between the 'delete' and 'dispose' C++ operators with regards to dynamic memory allocation? ...

Resolving the wait situation for a detached thread in IPhone ?

Hello all, I am using a private MBProgressHUD Now I am using the indicator view on my add button in which I am calling my addrecord service . UIWindow *window = [UIApplication sharedApplication].keyWindow; HUD = [[MBProgressHUD alloc] initWithWindow:window]; // Add HUD to screen [window addSubview:HUD]; // Regisete for HUD callb...

Matlab: avoiding memory allocation in mex

I'm trying to make my mex library avoid all memory allocation what so even. Until now, the mex got an input, created some matrices using mxCreate...() and returned this output. But now I'd like to modify this interface so that the mex itself would not do any allocations. What I had in mind is that the mexFunction will get as input the ma...

Why does my program stop crashing if I call malloc instead of GetMem?

I am calling a C DLL from a Delphi 2009 application and I keep getting errors when memory allocated by GetMem or AllocMem is passed to the DLL. The only way around I could avoid these errors was by using malloc from msvcrt.dll. What is malloc doing that the built-in memory routines aren't, and how can I get the built-in ones to work? I r...

How can I use up RAM quickly to test garbage collection?

Windows Server 2008. How can I quickly use up RAM so to induce GC in my app. If there is a way to do it without needing Visual Studio or installing a language runtime it would be good. EDIT: I don't want to have to write an app and then copy it over to the server. I'm looking for a way to do it quickly without writing an app that requir...

%d doesn't show integer properly

As I try to write NSLog(@"%d", myObject.myId); where myId is int, console gives some hight number like 70614496. And when I use @"%@", I get exception -[CFNumber respondsToSelector:]: message sent to deallocated instance 0x466c910. Why is it so? Here's definition of myObject: @interface myObject : NSObject { int myId; NSString *titl...

What Operating Systems Will Free The Memory Leaks?

I've got a desktop program. Most Operating Systems run the program in its own address space. When the program exits, I believe most operating systems free the memory allocated by the program and return it to the memory stack for reuse. What I am not sure of, is if the program has a memory leak, will the memory "leaked" also be returne...

Best practice for assigning new objects to retained properties?

I am using Core Data for my iPhone app. My attributes are set with retained properties. For example, a "number" attribute in a "Thing" entity: #import <CoreData/CoreData.h> @interface Thing : NSManagedObject { } @property (nonatomic, retain) NSNumber * number; @end @implementation Thing @dynamic number; @end When working with...

iphone memory deallocation issue with scrollview with image inside

Hi, I'm having trouble deallocating a UISCrollView that contains images. There's something wrong with my code, but I cannot understand where. this is a snippet of my code. It basically create a loops adding a uiscrollview with an image and removing. If you run the code with instruments, no memory will be freed. I also add some check for...

catching write faults on write protected memory

I am trying to catch write faults on write protected memory pages from my program. I have done following to achieve this : protect memory page using mprotect() : allowing only read access register signal handler for SIGSEGV called write-fault-handler using sigaction() inside signal handler : siginfo->si_addr gives me memory addres...

Clicking in UISearchBar causes memory leak

I have been getting a weird memory leak and i just pinpointed what is causing. I am using a utility application that has a main view and a flipside view. When you are on the flipside view you are able to present another modal view by clicking a plus button. This view has a UISearchBar and UITableView. When clicking on the UISearchBar...

C: Correctly freeing memory of a multi-dimensional array

Say you have the following ANSI C code that initializes a multi-dimensional array : int main() { int i, m = 5, n = 20; int **a = malloc(m * sizeof(int *)); //Initialize the arrays for (i = 0; i < m; i++) { a[i]=malloc(n * sizeof(int)); } //...do something with arrays //How do I fre...

How to interpret some of the Error messages from Xcode console?

Hi As my programs involves more and more code Im starting to get a bit frustrated with the error messages that are thrown in the console: 2009-11-14 14:31:57.513 FC[915:5b27] *** -[SearchResultParser respondsToSelector:]: message sent to deallocated instance 0x82d28e0 This one is not the worst as it actually tells me that it has t...

Core Data Memory Management

Hi there, I've read the memory management sections in the Core Data docs and I'm still a little confused. I have one context in my app, and I have several things getting objects out of it. For example a few fetched results controllers, detail views and some other code fetching random objects. Once objects have been fully released and th...

Is there garbage collection in PHP?

I know that in PHP you don't have to free memory. Is it reached by garbage collector? ...

Utilizing less memory in ASP.NET

My asp.net application is 3 static pages (no database) and it initializes with 48Mb of memory in use. Can I configure the application to use less memory? NB: I've already set the memory limits in IIS. I set maximum value for working process to 30 MB of physical memory. What other ways can I employ to make ASP.NET use less memory...