memory-management

Can Win32 "move" heap-allocated memory?

I have a .NET/native C++ application. Currently, the C++ code allocates memory on the default heap which persists for the life of the application. Basically, functions/commands are executed in the C++ which results in allocation/modification of the current persistent memory. I am investigating an approach for cancelling one of these f...

O(1) lookup in non-contiguous memory?

Is there any known data structure that provides O(1) random access, without using a contiguous block of memory of size O(N) or greater? This was inspired by this answer and is being asked for curiosity's sake rather than for any specific practical use case, though it might hypothetically be useful in cases of a severely fragmented heap....

Memory still increasing when use CFRelease for ABRecordCopyValue???

hi everyone, i have a problem make headache, i simply create method: -(void) main{ for (int i = 0; i< 100;i++) { [self getPhoneOfContact:i]; } } -(void)getPhoneOfContact:(NSInteger)id_contact { ABRecordRef record = ABAddressBookGetPersonWithRecordID(addressBook,id_contact); CFTypeRef ref1; ref1...

Algorithm for allocating memory pages and page tables

I want to design an algorithm for allocating and freeing memory pages and page tables. What data structures would allow best performance and simplest implementation? ...

Difference between sequential write and random write

What is the difference between sequential write and random write in case of :- 1)Disk based systems 2)SSD [Flash Device ] based systems When the application writes something and the information/data needs to be modified on the disk then how do we know whether it is a sequential write or a random write.As till this point a write cannot b...

How to I serialize a large graph of .NET object into a SQL Server BLOB without creating a large buffer?

We have code like: ms = New IO.MemoryStream bin = New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bin.Serialize(ms, largeGraphOfObjects) dataToSaveToDatabase = ms.ToArray() // put dataToSaveToDatabase in a Sql server BLOB But the memory steam allocates a large buffer from the large memory heap that is giving us prob...

Is it possible to replace the global "operator new()" everywhere?

I would like to replace the global operator new() and operator delete() (along with all of their variants) in order to do some memory management tricks. I would like all code in my application to use the custom operators (including code in my own DLLs as well as third-party DLLs). I have read things to the effect that the linker will c...

Delegate variables not garbage collected

Recently discovered that the variables inside ToGadget, and presumably the delegate as well, weren't getting garbage collected. Can anyone see why .NET holds a reference to this? Seems that the delegate and all would be marked for garbage collection after Foo ends. Literally saw *B*illions in memory after dumping the heap. Note: 'res...

CakePHP Web Crawler Memory Leak

I am developing an application that is, to put it simply, a niche based search engine. Within the application I have include a function crawl() which crawls a website and then uses the collectData() function to store the correct data from the site in the "products" table as described in the function. The visited pages are stored in a dat...

how to use my_alloc for _all_ new calls in C++?

Imagine I'm in C-land, and I have void* my_alloc(size_t size); void* my_free(void*); then I can go through my code and replace all calls to malloc/free with my_alloc/my_free. How, I know that given a class Foo, I can do placement new; I can also overload the new operator. However, is there a way to do this for all my C++ classes? (...

Memory Allocation Question?

public static void Main() { Test t1 = new Test(); } when will t1 (reference variable) will get memory, at compile time or run time. I think it should be run time. But when I put a breakpoint at Main Method and Put a Watch for t1, it was null. So it means t1 was in memory. Please correct me If I am wrong. Edit: I h...

Working set of memory

Hi, Why does the memory decrease when you minimize an Application ? I found this out while running a Flash Application in IE. It was taking around 200 MB memory but when I minimized the IE it came down to 5 MB's. I saw similar behaviour with Outlook and other EXE's. I googled and found out that the working set of a process decreases w...

Memory management for intentionally memory intensive applications

Note: I am aware of the question Memory management in memory intensive application, however that question appears to be about applications that make frequent memory allocations, whereas my question is about applications intentionally designed to consume as much physical memory as is safe. I have a server application that uses large amou...

Does unsetting an array of objects unset just the array or also all the objects?

I have an array of objects. If I call unset($array), will it unset all objects in the array AND the array or just the array? Let's assume these objects are referenced nowhere else. ...

Does reassigning an array to another array free memory originally used by the array?

My class has a member variable array, items. Periodically I reassign the array to be the value of another, temporary array, like this: $temp = array(); $temp[] = new Object(); $temp[] = new Object(); $temp[] = new Object(); ... etc. $this->items = $temp; So, could I have a memory leak? By reassigning the value of $this->temp to a new...

[iPhone] release NSData in NSManagedObject

Hi, I use datamodel to store 2 objects : Video, Images. Video contain just string attributes and Images have 2 "Binary data" attributes. At the start the 2 binary data attributes was in the video object. But all videos are loading during initialization of UITableView. For 400 videos binary data represent 20 Mo, so imagine with 4000 vid...

Releasing NSArray containing NSDictionary objects

I am having difficulty getting my head around memory management in the following segment of code on iPhone SDK 3.1. // Create array to hold each PersonClass object created below NSMutableArray *arrayToReturn = [[[NSMutableArray alloc] init] autorelease]; NSArray *arrayOfDictionaries = [self generateDictionaryOfPeople]; [arrayOfDiction...

when does Python allocate new memory for identical strings ?

Two Python strings with the same characters, a == b, may share memory, id(a) == id(b), or may be in memory twice, id(a) != id(b). Try ab = "ab" print id( ab ), id( "a"+"b" ) Here Python recognizes that the newly created "a"+"b" is the same as the "ab" already in memory -- not bad. Now consider an N-long list of state names [ "Ari...

Uploading large video via Youtube API causing Out of Memory

I'm using PHP to send videos via Direct Upload to Youtube. It works fine for smaller sized videos but when trying to send a 390 MB video, I get the following error: PHP Fatal error: Out of memory (allocated 3932160) (tried to allocate 390201902 bytes) I've tried increasing memory_limit but that does not help. if ($isFile)...

Is this a memory leak? How should it be done?

Hello, I have something like this: void Test(void) { char errorMessage[256]; spintf(errorMessage,... blablabla); throw new CustomException(errorMessage); } Will this be a memory leak because errorMessage will be not freed? Or will this cause an exception when accessing the message of the exception inside a try{}catch beca...