memory-management

JavaScript new keyword and memory management

Coming from C++ it is hard grained into my mind that everytime I call new I call delete. In JavaScript I find myself calling new occasionally in my code but (hoping) the garbage collection functionality in the browser will take care of the mess for me. I don't like this - is there a delete method in JavaScript and is how I use it differ...

Memory pressure notification in SQL CLR

My dear friend google is not able to tell me if there is an API available inside the SQL CLR to get memory pressure notification. It is obviously used, since the AppDomain will get unloaded under memory pressure, but the question is if the notification is sent to into the AppDomain prior to the unload, so that I could release some cache...

How do i free objects in C#

Hi, Can anyone please tell me how I can free objects in C#? For example, I have an object: Object obj1 = new Object(); //Some code using obj1 /* Here I would like to free obj1, after it is no longer required and also more importantly its scope is the full run time of the program. */ Thanks for all your help ...

Is delete p where p is a pointer to array always a memory leak ?

following a discussion in a software meeting I've set out to find out if deleting a dynamically allocated, primitives array with plain delete will cause a memory leak. I have written this tiny program and compiled it with visual studio 2008 running on windows XP: #include "stdafx.h" #include "Windows.h" const unsigned long BLOCK_SI...

Cocoa Memory Management NSArray with Objects

Hi, I'm having troubles releasing objects.. To explain it better I have included my code below. NSTask *task = [NSTask new]; NSTask *grep = [NSTask new]; NSPipe *pipe = [NSPipe new]; [task setStandardError: pipe]; [grep setStandardInput: pipe]; [pipe release]; pipe = [NSPipe new]; [grep setStandardOutput: pipe]; [task launch]; [grep...

Small block allocator on Linux (or RedHat Linux) to avoid memory fragmentation

I know that there is an allocator for user applications than handles lots of small block allocation on HP-UX link text and on Windows XP Low-fragmentation Heap. On HP-UX it is possible to tune the allocator and on Windows XP it considers block of size less than 16 K as small. My problem is that I can't find any information about this ki...

Is it possible to compact the VC++ runtime heap?

Can I have the same effect as with HeapCompact() for the Visual C++ runtime heap? How can I achieve that? ...

Java VM - does the freed memory return to the OS?

In the Java runtime, if my application frees memory, does the runtime release the memory back to the OS? Or just back to my process? ...

How could VirtualAlloc fail (no mem) despite plenty of phys memory on WinMobile?

I am routinely seeing VirtualAlloc calls to reserve memory fail. I'm requesting 2MB so that the allocations do not count against my per process virtual memory and instead use system shared memory. At the time of failure, the system reports having over 100 MB available in physical memory. I'm running on a windows mobile 6.1 device. So f...

How else can I avoid leaking this Core Foundation object?

The following leaks: CFStringRef labelName = ABAddressBookCopyLocalizedLabel(ABMultiValueCopyLabelAtIndex(aMultiRef, indexPath.row)); cell.textLabel.text = (NSString *)labelName; CFRelease(labelName); Wondering if there a way to rewrite it so it doesn't leak without breaking out & assigning ABMultiValueCopyLabelAtIndex(aMultiR...

What does this error mean? malloc: *** error for object 0x103f000: pointer being freed was not allocated *** set a breakpoint in malloc_error_break to debug

What does that mean? Getting this in the console during usage of my app in debug mode: malloc: * error for object 0x103f000: pointer being freed was not allocated * set a breakpoint in malloc_error_break to debug Does that mean I'm over-releasing something? ...

Strange memory management issue

I can't identify the object being deallocated, I run my app with Command+Y but despite having MallocStackLogging set to YES and NSZombieEnabled set to YES, when I hit EXC_BAD_ACCESS in my app, gdb doesn't print the memory address of the deallocated object. Any ideas? Apologies if this seems vague, it looks like it's Core Data related, ...

Intel MKL memory management and exceptions

Hello everyone, I am trying out Intel MKL and it appears that they have their own memory management (C-style). They suggest using their MKL_malloc/MKL_free pairs for vectors and matrices and I do not know what is a good way to handle it. One of the reasons for that is that memory-alignment is recommended to be at least 16-byte and with...

Memory management in objective-c

I have this code in one of my classes: - (void) processArray { NSMutableArray* array = [self getArray]; . . . [array release]; array = nil; } - (NSMutableArray*) getArray { //NO 1: NSMutableArray* array = [[NSMutableArray alloc]init]; //NO 2: NSMutableArray* array = [NSMutableArray array]; . . . return...

Removing a view from it's superview causes memory error - why?

Xcode is throwing an error at me: malloc: * error for object 0x103f000: pointer being freed was not allocated * set a breakpoint in malloc_error_break to debug I tracked down the code until a line where I do this: - (void)inputValueCommitted:(NSString *)animationID finished:(BOOL)finished context:(void *)context { //...

Do I have a memory management problem in here?

Something must be wrong with this code right here: + (UIImage*)captureView:(UIView *)theView { UIGraphicsBeginImageContext(theView.frame.size); [theView.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return newImage; ...

delete vs delete[] operators in C++

What is the difference between delete and delete[] operators in C++? ...

Do I need to release a copied NSObjects - Objective-c

Hi everyone, I was wondering if I need to release a copied NSObject? For example, I create only one dictionary that I copy into an array: Code: for (int num = 0; num < [object count]; num++) { [dictionary setObject:[object objectAtIndex:num] forKey:@"x"]; [array addObject:[dictionary copy]]; } Do I have to release the diction...

How to implement didReceiveMemoryWarning ?

Hello all , I have developed a simple location aware iPhone application which is functionally working very well to our expectations except in the low memory condition of the phone . In low memory condition of the phone my app just got crashes and If I increases the phone memory by freeing up some space it again start working well witho...

How to allocate more memory for a buffer in C++?

I have pointer str: char* str = new char[10]; I use the memory block str points to to store data. How can I allocate more bytes for the buffer pointed to by str and not lose old data stored in the buffer? ...