memory-allocation

[Memory allocation problem]Unhandled exception: Microsoft C++ exception: std::bad_alloc at memory location

Hello everybody. I am using visual studio 2008 for developing. My program needs to deal with a huge amount of memory. The error happens when my program try to allocate a 512M float array. Code is the following: int size = 512*512*512; float *buffer = new float[size]; Before this allocation, the program already consumed around 554M me...

How is memory allocated for Hashtable?

When a hash table is initialized how is memory is allocated for it? When we add new members to it how does the memory used by the hash table get extended? Does it ever happen that a hash table is not able to store objects after a fixed size? ...

special mode for no free() on delete's? C++

I know this will sound weird but i need my app to run fast and it does a lot of new and delete. All function calls new and passes the ptr back expect for the ones pushing a pointer to a list or deque. At the end of the main loop the program goes across all of that memory and deletes it (unless i forgot to delete it). I am not exaggerati...

Released object crashes App -- problem with alloc/init memory management

I have a flipView class that I allocate and initiate. But, when I release it the app crashes. If I don't release it, the app works fine, so it seems. The error message I receive when I release it is: Malloc - error for object: object pointer being freed was not allocated. If you could please assist me, I would be grateful. - (IBA...

C++ Memory Allocation

When using C++, if there is a class: class MyClass { char memory1bye; int memory4bytes; int another4bytes; }; this class uses total of 9 bytes at memory… so if i do something like: MyClass *t1; This will give me a usable address for the Class, but will it allocate the 9 bytes? And will it call default constructor? Or ...

Tools for Memory leaks in .Net executable

Hello, I am trying to test an application in Windows for memory leaks. I have looked at Linux alternatives (eg. Valgrind) and I am looking for a similar tool for Windows. The problem with .Net is that the memory is not released straight away like in Linux. My knowledge of .Net is limited so my problem is I would like to use a tool tha...

Ruby/Rails memory usage

Hey guys, in the following code: def process(batch_size=1000) claim_numbers.each_slice(batch_size) do |numbers_batch| claims = Claim.find(:all, :conditions => ["claim_number in (?)", numbers_batch]) # do something with claims end end In one of my Rails models I'm processing a lot of claim_numbers, I'm simu...

Does libumem with mmap backend reuse anon pages for oversized allocations?

I have a program that uses Solaris' libumem memory allocator with mmap as a backend. That program does a lot of oversized (in terms of libumem slab concept) allocations. Does libumem in this situation cache oversized allocations, or are all those allocations made with fresh anon mmap() pages (and therefore initialized to zero)? ...

Stack and heap in c sharp

Possible Duplicate: Why are structs stored on the stack while classes get stored on the heap(.NET)? Can anyone tell me that how the allocation of memory is done that which object is to be stored in stack and which to be in heap portion of the memory? ...

deleteRowsAtIndexPaths doesn't release the cell?

Hi, I have a functionality in my table view i.e. when you tap in on cell it loads more cells in below the tapped cell and when you tap again on same cell those added cells gets deleted. But I have got a strange behavior that when i call below method to delete added cells from table view, the dealloc method of cell isn't being called..(...

Can a Memcached daemon ever free() unused memory, without terminating the process?

I believe that you can't force a running Memcached instance to de-allocate memory, short of terminating that Memcached instance (and freeing all of the memory it held). Does anyone know of a definitive piece of documentation, or even a mailing list or blog posting from a reliable source, that can confirm or deny this impression? As I un...

Memory allocation/reallocation question

I just finished working out a memory allocation problem with the current program I'm writing, but I am not happy with what I had to do to fix it. In my program, I was building up an array of structs, reallocating space for the array every time I wanted to add a struct to it. Here is a generic version of my struct and the function that ...

Creating an object on the stack then passing by reference to another method in C++

I am coming from a C# background to C++. Say I have a method that creates a object in a method on the stack, then I pass it to another classes method which adds it to a memeber vector. void DoStuff() { SimpleObj so = SimpleObj("Data", 4); memobj.Add(so); } //In memobj void Add(SimpleObj& so) { memVec.push_back(so); //boost...

C 2D array Memory allocation

Greetings all, Is there any issue in the following logic for allocating 2D array: unsigned char ** Malloc2D_uchr(int ht, int wt, unsigned char initv) { int h, w; unsigned char **x; x = (unsigned char **) malloc(sizeof(void *) * ht); DEBUG_PRINT_MEMLOC_EXIT(x,"malloc failed (%s,%i)\n",sizeof(void *)*ht); x[0] = (uns...

How to declare and use huge arrays of 1 billion integers in C ?

I'm implementing a sequential program for sorting like quicksort. I would like to test the performance of my program in a huge array of 1 or 10 billions of integers. But the problem is that I obtain a segmentation error due to the size of the array. A sample code of declaration of this array: #include <stdio.h> #include <stdlib.h> #inc...

Why doesn't strncpy work with a string allocated with malloc?

char* temp; temp = (char*) malloc (strlen(window->entry.value)+1); //strncpy( temp, window->entry.value, sizeof(temp) ); DOESN"T WORK memcpy (temp, window->entry.value, strlen(window->entry.value) + 1); //WORKS (where window->entry.value is a string.) Thanks. ...

how storage is reserved by SQL Server? and howto overrule it ?

I am trying to understnad how SQL Server allocates and reserves space. Having run the examples from the article "How table design can impact your SQL Server performance?" [1], I received the results [My 1.1] diverting from those in article [1.1]. Why? Why in one case the excessive space is reserved/allocated (all cases in [1]) but ...

In which segment is memory for library functions allocated?

The way automatic variables/local variables go on to stack,dynamically allocated objects/data type go on to heap; where is the memory for library function calls (say printf()) allocated. In which segment? ...

Stack and Heap Space for Modern Computers

When writing in C, how can I tell how much stack space is available in memory when I launch a program? How about heap space? How can I tell how much memory is being used during the execution of my program? ...

Tokenize an environment variable and save the resulting token in a char**

Hi. I'm attempting to create an array of strings that represent the directories stored in the PATH variable. I'm writing this code in C, but I'm having trouble getting the memory allocation parts working. char* shell_path = getenv ("PATH"); char* tok = strtok (shell_path, SHELL_PATH_SEPARATOR); int number_of_tokens = 0, i = 0; while (...