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...
Hello,
I've recently been playing with code for an iPhone app to parse XML. Sticking to Cocoa, I decided to go with the NSXMLParser class. The app will be responsible for parsing 10,000+ "computers", all which contain 6 other strings of information. For my test, I've verified that the XML is around 900k-1MB in size.
My data model is to...
Hi guys,
we are planing an app for blackberry app world and will have to load lots of textures and audiofiles.
so we need to know how much memory the app can really allocate for a smarthphone with 64MB (RAM)
thx for answers!
...
I am getting a "bitmap size exceeds VM budget" error. I have read that there is a 16MB memory limit. In this thread Romain Guy says that "you can only allocate 16 MB
of memory for your entire application".
However, my app must be running out of memory long before it reaches that limit. So my question is: how do I allocate memory to my ...
What is the best way to zero out new memory after calling realloc while keeping the initially allocated memory intact?
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include <stdio.h>
size_t COLORCOUNT = 4;
typedef struct rgb_t {
int r;
int g;
int b;
} rgb_t;
rgb_t** colors;
void addColor(size_t i, int r, i...
I am allocating some float arrays (pretty large, ie 9,000,000 elements) on the GPU using cudaMalloc((void**)&(storage->data), size * sizeof(float)). In the end of my program, I free this memory using cudaFree(storage->data);.
The problem is that the first deallocation is really slow, around 10 seconds, whereas the others are nearly inst...
I'm writing a bit of code for a class, but since I have no experience in C I'm a bit unsure of what the code I've written actually does. Particularly what the memory looks like. Here's the relevant bits:
typedef struct listnode *Node;
typedef struct listnode {
void *data;
Node next;
Node previous;
} Listnode;
typedef struct...
I am writing my own string copy function. The following works:
char *src, *dest;
src = (char *) malloc(BUFFSIZE);
//Do something to fill the src
dest = (char *) malloc(strlen(src) + 1);
mystringcpy(src, dest);
void mystringcopy(char *src, char *dest) {
for(; (*dest = *src) != '\0'; ++src, +dest);
}
But this doesn't work:
char *sr...
We are using visual studio 2008-My requirement is to allocate some memory, store data into that allocated memory and pass the memory address to a DLL written in C. But when try to pass this memory address to a function in that DLL my application crashes and shows the message "The memory could not be written".
''//Memory allocation Code
...
What is difference in memory management of variables a and b?
Are they both similar static variables but visibility of b is local?
Is it ok to declare static variable in procedure or function?
const
a: string = 'aaa';
procedure SubMethod;
const
b: string = 'bbb';
begin
a := a + 'a';
b := b + 'b';
end;
...
Possible Duplicate:
Any reason to overload global new and delete?
In what cases does it make perfect sense to overload operator new?
I heard you do it in a class that is very often allocated using new. Can you give an example?
And are there other cases where you would want to overload operator new?
Update: Thanks for all ...
I'm just beginning to get into C++ and I want to pick up some good habits. If I have just allocated an array of type int with the new operator, how can I initialise them all to 0 without looping through them all myself? Should I just use memset? Is there a C++ way to do it?
...
An application I am working with is exhibiting the following behaviour:
During a particular high-memory operation, the memory usage of the process under Task Manager (Mem Usage stat) reaches a peak of approximately 2.5GB (Note: A registry key has been set to allow this, as usually there is a maximum of 2GB for a process under 32-bit Wi...
Let's say I have the following C code:
int main () {
int *p = malloc(10 * sizeof *p);
*p = 42;
return 0; //Exiting without freeing the allocated memory
}
When I compile and execute that C program, ie after allocating some space in memory, will that memory I allocated be still allocated (ie basically taking up space) after I exi...
Hello:
I'm getting some odd behavior in one of my class members and it is truly throwing me for a loop but I'm certainly not seeing the issue (long week!)
void MyFakeStringClass::readStream( iostream& nInputStream )
{
// Hold the string size
UINT32 size = 0;
// Read the size from the stream
nInputStream.read( reinterpr...
Hello SO,
Is the max limitation for malloc (virtual heap I guess?) for a 32-bit app on a 64-bit system (Windows 2003 SP2 x64, to be specific) 2GB?
I'm basically trying to push a program beyond that with no luck. So I was wondering if that holds true for ALL 32-bit apps on Win x64 bit platforms.
Thank you!
...
Segments of memory - BSS, Stack, Heap, Data, Code/Text (Are there any more?).
Say I have a 128MB RAM, Can someone tell me:
How much memory is allocated for each of these memory segments?
Where do they start? Please specify the address range or something like that for better clarity.
What factors influence which should start where?
...
I often use convenience functions that return pointers to static buffers like this:
char* p(int x) {
static char res[512];
snprintf(res, sizeof(res)-1, "number is %d", x));
return res;
}
and use them all over the place as arguments to other functions:
...
some_func( somearg, p(6) );
....
However, this "convenience" ha...
Looking at this question that has just been asked: http://stackoverflow.com/questions/2231317/inconveniences-of-pointers-to-static-variables would doing something like this be considered bad practice, then?
char* strpart(char* string, int start, int count)
{
char* strtemp;
int i = 0; int j = 0;
int strL = strlen(string);
...
I've been constructing my own compiler and one large part of it is obviously the register allocator, which matches up temporary variables with machine registers as efficiently as possible. On an architecture such as the x86 there aren't many registers so there are a number of spills in which variables must be stored in memory (the stack)...