memory

why did my app just used about 36MB memory but i still receive low memory warning?

i use instruments to track my app's usage of memory,in memory monitor,i find that real memory is below 36MB ,and most time it just 32MB,but i still get warnings low memory in organizer and crashed. Incident Identifier: CFEF044E-E839-4DB7-9ED6-E22CD92B9171 CrashReporter Key: 80954447762f1882da7df309d5493cf8647f4c8b OS Version: ...

Non 8 Byte aligned memory access causes memory access violation on iPhone 3GS with iOS 4.0

Hi, consider the following Objective-C++ iPhone Application (TestMemAppDelegate.mm). It crashes with an EXC_BAD_ACCESS on the iPhone (3GS with iOS 4.0). It works fine in the Simulator. It is clearly a memory alignment thing, because it works fine on the iPhone if the "DataA" struct starts on a 8 Byte border. Can anyone explain the caus...

Does having lots of methods on a class increase the overhead of that class's object?

Imagine I am using a class to bring back items from a database, say class BankRecord { public int id; public int balance; public void GetOverdraft() { ... } public void MakeBankrupt(){ ... } } Now, what would happen to the performance of using this if there were just 2 methods (as above) or 100 methods, maybe some of them very larg...

On a Windows Mobile device, does it make sense to cache data "in memory"?

I'm writing a Windows CE application, and I want to play a sound (a short wav file) when something happens. Since this sound will be played often, my first instinct was to load the wav file into a memory stream and reuse that stream instead of reading the file every time. But then it occured to me that these Windows Mobile devices only ...

Java application : ask to wait in case of memory overflow

I am having a java application and spawns lot of threads..and due to out of memory error..it dies if it runs for too much time.. Is there a jvm configuration parameter, that I can set so that it will wait for memory when no memory is available, instead of throwing out of memory error. ...

Java Object and array memory location

I'm writing an array-backed hashtable in Java, where the type of key and value are Object; no other guarantee. The easiest way for me code-wise is to create an object to hold them: public class Pair { public Object key; public Object value; } And then create an array public Pair[] storage = new Pair[8]; But how does the j...

.NET should I store references or values?

I need to store in my object which values have already been handlerd, I am doubting what would cost more performance, should I create an array that stores: The instance references (they are not structs, only ref classes) The hashcode of the items The name of the name of the properties (string) that have been handled Update my aim is ...

How to obtain the consumption memory of running "exe"

Hello,my friend. I'm developing an "Online Judge System",like SGU "http://acm.sgu.ru/" I wangt to obtain the accurate consumption memory of running ".exe"(.c/.cpp-->.exe) using Java. Process : submit code-->hello.cpp/.c--compile-->hello.exe--run-->results I want to know how to obtain the consumption memory of running "hello.exe" Th...

How to use MemoryPoolMXBean

Hi all. We develop a server and we want to program congestion control into it. What we want to do is detect when free heap is below a certain threshold and stop accepting new data until free memory goes up again. Our first approach used runtime.freeMemory. This caused false positives as free heap went below the threshold before GC kicked...

QThread and reading memory.

Dear All: I have faced such a problem. I have a library which allows through UDP inter-process communication. It is very straight forward. The library creates shared memory available for other processes to write and read from. When process wants to read a interested memory it passes a string value which uniquely points to corresponding ...

How is (dynamic) memory traversed by a garbage collector?

I've read about the different kinds of GC and how they work. All involve traversing the set of memory which might potentially be reclaimed, but nothing I've read gives any indication as to how this is actually done. Would something like the following be way off the mark? void* myAlloc(size_t size) { if (needToGc()) gc(); ...

NSArray randomly turning into different things!

I am having a problem with memory management I think. My NSArray (called arr) is turning into different things at random times. I have no idea why. I have a .h file that that declares the array, and then I initialize the array using NSString *input = [[NSString alloc] initWithData:myData encoding:NSACIIStringEncoding]; arr = [input com...

In C++, what happens when the delete operator is called?

In C++, I understand that the delete operator, when used with an array, 'destroys' it, freeing the memory it used. But what happens when this is done? I figured my program would just mark off the relevant part of the heap being freed for re-usage, and continue on. But I noticed that also, the first element of the array is set to null,...

How are structs laid out in memory in C++?

Is the way C++ structs are laid out set by the standard, or at least common across compilers? I have a struct where one of its members needs to be aligned on 16 byte boundaries, and this would be easier if I can guarantee the ordering of the fields. Also, for non-virtual classes, is the address of the first element also likely to be th...

Why does a pointer's allocated memory persist after a function, but not an array?

So, I ask this question in the context of a basic text input function I see in a C++ book: char *getString() { char temp[80]; cin >> temp; char * pn = new char[strlen(temp + 1)]; strcpy(pn, temp); return pn; } So temp declares an array of 80 chars, an automatic variable whose memory will be freed once getString() r...

The order of data in memory

A few simple questions. const int gFirst; const int gSecond; struct Data { static int First; static int Second; int first; int second; }; Data data; Is it guaranteed that the following statements are true? 1) &gFirst < &gSecond 2) &Data::First < &Data::Second 3) &data.first < &data.second ...

How do C++ progs get their return value, when a return is not specified in the function?

Hi Everyone, I recently wrote a post: http://stackoverflow.com/questions/3452355/weird-error-in-c-program-removing-printout-breaks-program ...in which I was trying to solve a seemingly baffling problem, in which removing a cout statement would break my program. As it turned out, my problem was that I forgot to return my true/false succ...

How to tell when a Java object's memory is released?

I have a Swing browser application with a bug that as I add/remove to/from the GUI the memory isn't released for those objects and I'm trying to track down what is holding onto them. Problem is I don't know how to tell when something has actually be fully released from memory. Is there a way to tell if an object has been released from ...

Free memory and nil in Delphi using a single function.

I have a lot of memory allocations and the same number of FreeMem calls. What I didn't have though is a check before calling freemem to see if the pointer was nil, and a line after freeing to set the pointer to nil. I tried to create a function to do this procedure FreeMemAndNil(p: Pointer; size: Integer = -1); begin if p <> nil t...

How can I check if there is enough memory to process a picture captured by UIImagePickerController when taking multiple pics with the camera?

I am writing an application that uses UIImagePickerController to take multiple pictures with the camera as fast as iOS allows. My application has to run on iOS 3.13 on all versions of iPhone hardware (v1 through 4). I am using UIImagePickerController with a cameraOverlayView. My question is, how can I determine programmatically how man...