memory-management

How to allocate memory in another process for windows mobile

I'd like to read the contents of another process listview control in windows mobile. To do this, I need a pointer to some free memory to that process in order to put the values there (and then read them from my process). This can be done in normal Windows or Win32 with the VirtualAllocEx function. However, this function is not supporte...

When are variables removed from memory in C++?

I've been using C++ for a bit now. I'm just never sure how the memory management works, so here it goes: I'm first of all unsure how memory is unallocated in a function, ex: int addTwo(int num) { int temp = 2; num += temp; return num; } So in this example, would temp be removed from memory after the function ends? If not,...

Locate bad memory access on Solaris

On Linux, FreeBSD and other systems I have valgrind for checking for memory errors like invalid reads and similar. I really love valgrind. Now I have to test code on Solaris/OpenSolaris and can't find a way to get information on invalid reads/writes in an as nice way (or better ;-)) as valgrind there. When searching for this on the net ...

Java ME out of memory

Hello everybody, Im making Java me application for Symbian S60 5th edition and I have problem with the memory. After some time of running the app I recieve the out of memory exception. So,Im getting images from GoogleMaps(by the integrated GPS in nokia 5800) and showing them. I have this implemented like this: class MIDlet with metod...

How important is it to check return values when using the Python C API?

It seems that everytime I call a function that returns a PyObject*, I have to add four lines of error checking. Example: py_fullname = PyObject_CallMethod(os, "path.join", "ss", folder, filename); if (!py_fullname) { Py_DECREF(pygame); Py_DECREF(os); return NULL; } image = PyObject_CallMethodObjArgs(pygame, "image.load", py_...

c++ fread jibberish

For some reason my buffer is getting filled with jibberish, and I'm not sure why. I even checked my file with a hex editor to verify that my characters are saved in a 2 byte unicode format. I'm not sure what's wrong. [on file open] fseek(_file_pointer, 0, SEEK_END); this->_length = ftell(this->_file_pointer) / sizeof(chr); [Main] //...

Avoid making copies with vectors of vectors

I want to be able to have a vector of vectors of some type such as: vector<vector<MyStruct> > vecOfVec; I then create a vector of MyStruct, and populate it. vector<MyStruct> someStructs; // Populate it with data Then finally add someStructs to vecOfVec; vecOfVec.push_back(someStructs); What I want to do is avoid having the copy ...

iPhone memory management question: retaining iterated UITableViewCells?

I'm still shaky on the subtler aspects of memory management, and I have a question about the aggressive retaining/releasing I've seen in some sample code. Specifically: - (void)loadContentForVisibleCells { NSArray *cells = [self.tableView visibleCells]; [cells retain]; for (int i = 0; i < [cells count]; i++) { ...

Unit testing C library, memory management.

I am working on a quite large C library that doesn't have any tests now. As the API starts to be final, I'd like to start writing unit tests. Nearly all my functions acts on the first parameter (a structure). The naive approach to unit test is to have the pre function call structure in a known state, call the function, and then compare...

Core data and custom NSCell

I am building a toy app using core data for two entities Log (attributes text and date) and Tag with a many-to-many tags relationship from Log to Tag. I want to show logs in a table, so I: created an NSArrayController instance, LogController in IB with entity set to Log (pic) created a one-column NSTableView whose column is bound to ...

structure on a heap memory

This question was recently asked to me in an interview for which i went confused!! "How do you initialize a structure in the heap memory ?" could anybody please tell me the correct answer for this? btw:how exactly are stack and heap memory are different from each other? And looking about the above question some might also ask me about ...

Whats the work of JDK and JRE?

Hi, I have a confusion that what JRE is doin on the Background and what does the JDK doing. ...

Is memory management a concern with asp.net mvc

Hai guys, I want to know,is memory management a concern with asp.net mvc.. comparision of memeory management in both asp.net mvc and web forms by experts ...

Why array values in java is stored in heap?

Programing languages like C,C++ will not store array values in Heap rather it keeps the value in STACK. But in Java why there is a necessity to keep array values in heap? ...

What do I need to know about memory in C++?

I've been doing my best to learn C++ but my previous training will fall short in one major issue: memory management. My primary languages all have automatic garbage collection, so keeping track of everything has never really been necessary. I've tried reading up on memory management in C++ online, but I have this shaking suspicion that...

Are spinlocks a good choice for a memory allocator?

I've suggested to the maintainers of the D programming language runtime a few times that the memory allocator/garbage collector should use spinlocks instead of regular OS critical sections. This hasn't really caught on. Here are the reasons I think spinlocks would be better: At least in synthetic benchmarks that I did, it's several t...

If I have a variable locally declared in a loop that creats a thread, is it safe to use that variable in the called thread, even after the next iteration of the loop takes place?

I have a question about variable scope and memory management in C. I am writing a program that listens for a socket connection and then launches a new thread to handle that client. The main while() loop can launch many separate threads. My question is this: If I don't use dynamic memory allocation [no malloc()], and instead have a va...

How could pairing new[] with delete possibly lead to memory leak only?

First of all, using delete for anything allocated with new[] is undefined behaviour according to C++ standard. In Visual C++ 7 such pairing can lead to one of the two consequences. If the type new[]'ed has trivial constructor and destructor VC++ simply uses new instead of new[] and using delete for that block works fine - new just call...

Local object scope and memory management in Cocoa

I'm new to Objective-C and Cocoa programming, so in my first sample projects I've always adopted the statement of releasing/autoreleasing all my allocated and copied objects. But what about local objects allocated inside methods? Let me write some sample code, here is my object interface: @interface MySampleObject : NSObject { NSMe...

Why does the OutOfMemoryException get thrown?

What reasons cause the .NET runtime to throw an OutOfMemoryException? The garbage collector's job is to clean up memory and free memory as necessary before allocating objects; why would it appear to be out of memory? ...