memory-management

How can I reserve memory for pointer to an array in Delphi?

Hi everybody. I'm developing class to represent special kind of matrix: type DifRecord = record Field: String; Number: Byte; Value: smallint; end; type TData = array of array of MainModule.DataRecord; type TDifference = array of DifRecord; type TFogelMatrix = class private M: Byte; N: Byte; Data: ^...

How to deal with low memory warnings on the iPhone?

I'm having problems with my application receiving low memory warnings while the user is deep within a navigation controller stack of views. After the user browses through a bunch of hierarchical options in subsequent UITableViews, he can open a PDF document in a UIWebView (in a different view controller). Everything works fine, the PDF ...

Since .NET has a garbage collector why do we need finalizers/destructors/dispose-pattern?

If I understand correctly the .net runtime will always clean up after me. So if I create new objects and I stop referencing them in my code, the runtime will clean up those objects and free the memory they occupied. Since this is the case why then do some objects need to have a destructor or dispose method? Won’t the runtime clean up af...

Is "Out Of Memory" A Recoverable Error?

I've been programming a long time, and the programs I see, when they run out of memory, attempt to clean up and exit, i.e. fail gracefully. I can't remember the last time I saw one actually attempt to recover and continue operating normally. So much processing relies on being able to successfully allocate memory, especially in garbage c...

How is Memory Organized in Windows?

I'm looking for an explanation or good free online resources about the organization of memory and memory management in Windows systems. ...

Memory management practices and tools for Symbian C++

Hi, I have pretty much finished my first working Symbian application, but in my hastened learning have paid little attention to memory management and pushing to and cleaning up the stack? Could somebody please point me in the direction of some of the best practises to use here, and maybe some of the best leak detection/memory profiling...

How's memory allocated for a static variable?

In the below program Class Main{ static string staticVariable = "Static Variable"; string instanceVariable = "Instance Variable"; public Main(){} } The instanceVariable will be stored insided the memory allocated for object instance. Where will the static variable go, Is it stored in the object instance itself or some where else? I...

SmartAssembly memory management

Hi All, Just came across this website. Feature 9 is memory management and they claim that their product "automatically releas[es] memory [that is] no longer needed." Is this a marketing ploy, or do you think they have some trick up their sleeves? Are they just making a claim based on what they .Net runtime provides in any case (or are ...

Is it safe to use STL (TR1) shared_ptr's between modules (exes and dlls)

I know that new-ing something in one module and delete-ing it in another can often cause problems in VC++. Problems with different runtimes. Mixing modules with staticly linked runtimes and/or dynamically linked versioning mismatches both can screw stuff up if I recall correctly. However, is it safe to use VC++ 2008's std::tr1::shared_p...

Parsing very large XML documents (and a bit more) in java

(All of the following is to be written in Java) I have to build an application that will take as input XML documents that are, potentially, very large. The document is encrypted -- not with XMLsec, but with my client's preexisting encryption algorithm -- will be processed in three phases: First, the stream will be decrypted according ...

Should I use Objective-C garbage collection when writing for 10.5+?

When writing fairly typical Mac code in an OS X 10.5+ environment, what are the disadvantages to using garbage collection? So far everything else I've written has been either 10.4 compatible or on the iPhone, so I've become fairly comfortable with retain/release, but now that I'm working on a larger project that's 10.5 only I'm wonderin...

How can I determine how much memory my .NET program is using?

It seems to be often said that Task Manager does not provide an accurate indication of how much memory is in use by a process. If this is indeed the case, what's the easiest way to find these things out? I'd like to know: Total Memory in use (whether in RAM or paged or whatever) Total RAM in use (running in a situation where the mach...

When does CLR say that an object has a finalizer ?

I know that in C#, if you write ~MyClass(), this basically translates to override System.Object.Finalize(). So, whether you write the destructor or not, every type in CLR will have a Finalize() method in it (of System.Object at least). 1] So, does it mean that, every object, by default, has a finalizer ? 2] What is the basis for the CL...

How to store data in variable length arrays without causing memory corruption?

This is a fairly basic question, which for some reason, a proper solution escapes me at the moment. I am dealing with a 3rd-party SDK which declares the following structure: struct VstEvents { VstInt32 numEvents; ///< number of Events in array VstIntPtr reserved; ///< zero (Reserved for future use) VstEvent* events[2]; //...

What's wrong with this memory allocation

Hi guys, I tried to make a dynamic 2D array of char as follow: char** ppMapData = (char**)malloc(sizeof(char*)*iMapHeight); for (int i=0; i< iMapHeight; i++) { ppMapData[i] = (char*)malloc(sizeof(char)*iMapWidth); //do something } // do something for (int i=0; i<iMapHeight; i++) free(ppMapData[i]); free(ppMapData); It lo...

initializing std::string from char* without copy

I have a situation where I need to process large (many GB's) amounts of data as such: build a large string by appending many smaller (C char*) strings trim the string convert the string into a C++ const std::string for processing (read only) repeat The data in each iteration are independent. My question is, I'd like to minimise (if ...

How do realloc and memcpy work?

Dear all, Here are my questions... 1- Do realloc and memcpy copy the entries in an array to another in a way faster than just iterating on each element O(N) ? If the answer is yes then what do you think is its complexity ? 2- If the size allocated is smaller than the original size, does realloc copy the entries to somewhere else or jus...

Understanding the memory consumption on iPhone

Hello! I am working on a 2D iPhone game using OpenGL ES and I keep hitting the 24 MB memory limit – my application keeps crashing with the error code 101. I tried real hard to find where the memory goes, but the numbers in Instruments are still much bigger than what I would expect. I ran the application with the Memory Monitor, Object ...

Deallocation doesn't free mem. in Windows/C++ Application

Hi, My Windows/C++ application allocates ~1Gb of data in memory with the new operator and processes this data. The data is deleted after processing. I noticed that if I run the processing again without exiting the application, the second call to "new" operator to allocate ~1gb of data fails. I would expect Windows to deliver back the ...

When and why will an OS initialise memory to 0xCD, 0xDD, etc. on malloc/free/new/delete?

I know that the OS will sometimes initialise memory with certain patterns such as 0xCD and 0xDD. What I want to know is when and why this happens. When Is this specific to the compiler used? Do malloc/new and free/delete work in the same way with regard to this? Is it platform specific? Will it occur on other operating systems, suc...