memory

Heap / Stack and multiple processes

Hi, Say I have two process p1,p2 runnning as a part of my application. Say p1 is running initially executing function f1() and then f1() calls f2().With the invocation of f2() process p2 starts excuting What I want to confirm is it that :- 1)Do we have seperate stack for different process? 2)Do we have seperate heap for different proc...

java.lang.OutOfMemoryError: bitmap size exceeds VM budget - android - how many images?

Hi I am developing an android app and as I read all around and learned for myself, I cant have a lot of images on the screen at the same time or I will get an exception. The question is how many images or how many KB in images or how many layouts/images can I have at the same time in the screen. I know this is not the only thing that...

Showing Large PNG image in an Adobe Air application

I've got a bare minimum Adobe Air application; it's basically a s:SkinnableContainer inside a mx:WindowedApplication. I have a 6000 x 9000 pixel PNG image (~3.20MB) that I want to show in the SkinnableContainer. Note that the s:SkinnableContainer is a tag from Flex 4 Beta3 (spark components). Background Before I explain the problem, a ...

Is it better to use an in-memory database (e.g. SQLite) than to keep everything in HashMap or other data structures?

I need to have very fast access to a big Map - several millions of entries. Is it worth using an SQLite in-memory database to keep that map as opposed to just having that HashMap in memory? ...

How do free and malloc work in C?

I'm trying to figure out what would happened if I try to free a pointer "from the middle" for example, look at the following code: char *ptr = (char*)malloc(10*sizeof(char)); for (char i=0 ; i<10 ; ++i) { ptr[i] = i+10; } ++ptr; ++ptr; ++ptr; ++ptr; free(ptr); I get a crash with an Unhandled exception error msg. I want to understand...

Defining minimum memory and free disk space requirements?

On page 42 of Code Code complete there's a checklist of requirement items you might want to consider during a requirement phase. On of the items (near the bottom of the list) says Are minimum machine memory and free disk space specified Has this ever been a requirement in any project you did and how did you define such a requirement befo...

OpenCL Texture Memory

I'm fairly new to OpenCL so please bear with me. In the first iteration of my code, I used basic memory buffers for large datasets and declared them global. However now that I'm looking to improve the timing, I wanted to use texture memory for this. In the CUDA version, we use cudaBindTexture and tex1Dfetch to obtain the data for a larg...

Which one to use - memmove() or memcpy() - when buffers don't overlap?

Using memcpy() when source and destination overlap can lead to undefined behaviour - in those cases only memmove() can be used. But what if I know for sure buffers don't overlap - is there a reason to use specifically memcpy() or specifically memmove()? Which should I use and why? ...

NSString memory leak

//opening DB if(sqlite3_step(statement) == SQLITE_ROW) result = [NSString stringWithUTF8String:(char*)sqlite3_column_text(statement,0)]; //! else result nil; return result; //close DB ...

OpenGL Video Memory Usage

Hello, is there an API or profiler application that can track the video memory usage of my application? I am using C++/OpenGL on Windows, but I am open to suggestions on other platforms as well. ...

Shared memory for fork

I want to create a shared memory between two process. I used fork(). A child tries to change this shared memory and mother creates another child so new child tries to change same memory so on. here is my code in C programing. (ubuntu) mylist ch=NUL; f=fork(); if(!f){ pba=shmget(KEYSHM,sizeof(char),0); /*created shared memory*/ ...

When should I use malloc in C and when don't I?

I understand how malloc() works. My question is, I'll see things like this: #define A_MEGABYTE (1024 * 1024) char *some_memory; size_t size_to_allocate = A_MEGABYTE; some_memory = (char *)malloc(size_to_allocate); sprintf(some_memory, "Hello World"); printf("%s\n", some_memory); free(some_memory); I omitted error checking for the sak...

One big pool or several type specific pools?

Hello, I'm working on a video game witch require high performance so I'm trying to setup a good memory strategy or a specific part of the game, the part that is the game "model", the game representation. I have an object containing a whole game representation, with different managers inside to keep the representation consistent, followi...

Using performSelectorInBackground to run loading indicator

I have such a code: [self performSelectorInBackground:@selector(indicator) withObject:nil]; [self mail]; //opening my controller of e-mail sending - (void)indicator { [actView startAnimating]; } This works fine, but i'm afraid of thread safety. I'm not allocating memory in a second thread, but smth tell's me that's too simple:) ...

more info on Memory layout of an executable program (process)

I attended interview for samsung. They asked lot of questions on memory layout of the program. I barely know anything about this. I googled it "Memory layout of an executable program". "Memory layout of process". I'm surprised to see that there isn't much info on these topics. Most of the results are forum queries. I just wonder why? ...

Finding a byte-pattern in some memory area

I want to search some memory range for a specific byte pattern. Therefore, my approach is to build a function void * FindPattern (std::vector<byte> pattern, byte wildcard, void * startAddress, void * endAddress); using the Boyer-Moore-Horspool algorithm to find the pattern in the memory range. The wildcard byte stays for some sp...

Track all Objective-C's alloc/allocWithZone/dealloc

Sorry for long description, however the questions aren't so easy... My project written without GC. Recently I found a memory leak that I can't find. I did use new Xcode Analyzer without a result. I did read my code line by line and verified all alloc/release/copy/autorelease/mutableCopy/retain and pools... - still nothing. Preamble: St...

Does WaitForSingleObject Serve as a Memory Barrier?

A question yesterday about doubled-checked locking started a chain of thoughts that left me unsure about a simple situation. In the following code, is it possible to hit the printf of “No longer in sync”? In this simple example, the values would likely be on the same cache line, so I think it would be less likely (assuming the possibili...

Objective-C: How to cast a boolean as an object for use with NSKeyedArchiver

I need to cast a boolean as an object, or NSKeyedArchiver throws a memory access error. What's the best way to do this? ...

mmap problem, allocates huge amounts of memory

I got some huge files I need to parse, and people have been recommending mmap because this should avoid having to allocate the entire file in-memory. But looking at 'top' it does look like I'm opening the entire file into the memory, so I think I must be doing something wrong. 'top shows >2.1 gig' This is a code snippet that shows what...