memory-allocation

How can I reclaim memory from perl?

Which is the way that I can reclaim memory back from my Perl script and/or to prevent perl from memory management pooling? ...

Heap fragmentation and windows memory manager

Hi, I'm having trouble with memory fragmentation in my program and not being able to allocate very large memory blocks after a while. I've read the related posts on this forum - mainly this one. And I still have some questions. I've been using a memory space profiler to get a picture of the memory. I wrote a 1 line program that conta...

When is stack space allocated for local variables?

I have a question about the following C code: void my_function() { int i1; int j1; // Do something... if (check_something()) { int i2; int j2; // Do something else... } // Do some more stuff... } Are there any guarantees about when stack space is allocated/deallocated for i2 and ...

The intricacy of a string tokenization function in C

For brushing up my C, I'm writing some useful library code. When it came to reading text files, it's always useful to have a convenient tokenization function that does most of the heavy lifting (looping on strtok is inconvenient and dangerous). When I wrote this function, I'm amazed at its intricacy. To tell the truth, I'm almost convi...

Memory Error in C++

Hi Guys, I have a high memory requirement in my code and this statement is repeated a lot of times: Node** x; x = new Node*[11]; It fails at this allocation. I figured out this line by throwing output to the console! I am building my code on Visual Studio. It works fine in Debug mode (both in VS2005 and VS2008) However it throws the ...

java and memory layout

Hey guys, I'm reviewing some questions but I can't really figure it out, i looked through the text book but i'm not sure where i can find answer... I know it would be quite hard to do memory diagrams w/o pictures but please bear with me. interface Lovable public void love(); class Foo implements Lovable public void love(); ...

Why can't compiler derive string length for array of strings?

Note: This question was influenced by this answer. The following is valid C code: char myString[] = "This is my string"; This will allocate a string of length 18 (including the \0 character) on the stack and assign the specified value to it. However, the following: char myStrings[][] = {"My 1st string", "My 2nd string", "My 3rd str...

Magic in placement new?

Hi, I'm playing with dynamic memory allocation "by hand" and I wanted to see how placement new is implemented by guys from MS but when debugging I "stepped into" it moved me to code: inline void *__CRTDECL operator new(size_t, void *_Where) _THROW0() { // construct array with placement at _Where return (_Where); } Could anyone explain...

RAM memory reallocation - Windows and Linux

I am working on a project involving optimizing energy consumption within a system. Part of that project consists in allocating RAM memory based on locality, that is allocating memory segments for a program as close as possible to each other. Is there a way I can know where exactly is the position of the memory I allocate (the memory chip...

CUDA Memory Allocation accessible for both host and device

I'm trying to figure out a way to allocate a block of memory that is accessible by both the host (CPU) and device (GPU). Other than using cudaHostAlloc() function to allocate page-locked memory that is accessible to both the CPU and GPU, are there any other ways of allocating such blocks of memory? Thanks in advance for your comments. ...

Windows Mobile 6 Emulator change storage?

Hey, How do i change the size of the Windows Mobile 6 Emulator. Its fixed at 32mb. I read this post: http://stackoverflow.com/questions/821720/increasing-windows-mobile-5-emulator-storage But it only helps for the 5.0 version. Isnt there any way to increase the storage size in version 6.0? ...

calling function from regular dll from c# - memory allocation issue?

Hi chaps(and chappettes) Have a regular C dll with an exported function int GetGroovyName(int grooovyId,char * pGroovyName, int bufSize,) Basically you pass it an ID (int), a char * buffer with memory pre-allocated and the size of the buffer passed in. pGroovyName gets filled with some text. (i.e. its a lookup basied on the groovyID)...

MATLAB: Determine total length/size of a structure array with fields as structure arrays

I have a structure array containing fields as structure arrays of varying length. For example: 's' is a structure 'data' is a field in 's', and also a structure array itself and length(s(n).data) ~= length(s(m).data) I want to preallocate an array that takes a time stamp from every field s.data.timestamp. Is there a way to do this wi...

What will happen if a application is large enough to be loaded into the available RAM memory?

There is chance were a heavy weight application that needs to be launched in a low configuration system.. (Especially when the system has too less memory) Also when we have already opened lot of application in the system & we keep on trying opening new new application what would happen? I have only seen applications taking time to proce...

Why Win32 HeapReAlloc() changes values?

Hi there! I'm writing an app in C using win32 API. When I try to enlarge the size of my array, using the HeapRealloc() function, it changes my current values in the array, instead of copying them. The code I use to reallocate memory: BOOL ChangeFeedArraySize(UINT newSize) { char tempChar[20] = ""; PFEED tempArr; if (newSi...

C++ message passing doubts

Hello, I'm writing a piece of sotware that needs objects that exchange messages between each other. The messages have to have the following contents: Peer *srcPeer; const char* msgText; void* payload; int payLoadLen; now, Peer has to be a pointer as I have another class that manages Peers. For the rest I'm doubtful... for example I m...

Memory leak/Memory allocation in C++

I have the following function in C++ void func1() { char *p = "Test for memory leak"; } When func1() is called where is the memory for the variable allocated? Whether in the stack or the heap? Should delete p; be called explicitly? ...

Cannot allocate new instance of UIView subclass after deallocating.

I have an instance variable *TangramLevel(:UIView) currentLevel; in my viewController class, and I have an instance allocated at start (it's retainCount 1). I attached it to the view [self.view addSubview:currentLevel]; (retainCount 2). When the level finishes, it notifies the controller, so controller removes it from the view [currentL...

dynamic allocation/deallocation of 2D & 3D arrays

I know about algorithms to allocate/deallocate a 2D array dynamically, however I'm not too sure about the same for 3D arrays. Using this knowledge and a bit of symmetry, I came up with the following code. (I had a hard time visualizing in 3D during coding). Please comment on the correctness and suggest any better alternative (efficien...

How does reflection affect Perm size?

I have the understanding that perm size is used to store meta data, that would include byte code, static stuff etc. My question how does usage of reflection affect the perm size, if it ever does. I mean if Program-A uses normal way of running objects and Program-B uses reflection all over, how will the perm-sizes of the two programs com...