memory-allocation

[C#] Not enough memory or not enough handles?

I am working on a large scale project where a custom (pretty good and robust) framework has been provided and we have to use that for showing up forms and views. There is abstract class StrategyEditor (derived from some class in framework) which is instantiated whenever a new StrategyForm is opened. StrategyForm (a customized window ...

Can I free memory passed to SysAllocString?

When allocating a new BSTR with SysAllocString via a wchar_t* on the heap, should I then free the original wchar_t* on the heap? So is this the right way? wchar_t *hs = new wchar_t[20]; // load some wchar's into hs... BSTR bs = SysAllocString(hs); delete[] hs; Am I supposed to call delete here to free up the memory? Or was that memo...

Allocating memory for a char pointer that is part of a struct

hi, im trying to read in a word from a user, then dynamically allocate memory for the word and store it in a struct array that contains a char *. i keep getting a implicit declaration of function âstrlenâ so i know im going wrong somewhere. struct unit { char class_code[4]; char *name; }; char buffer[101]; struct unit units[1000...

How to avoid the following purify detected memory leak in C++?

Hi, I am getting the following memory leak.Its being probably caused by std::string. how can i avoid it? PLK: 23 bytes potentially leaked at 0xeb68278 * Suppressed in /vobs/ubtssw_brrm/test/testcases/.purify [line 3] * This memory was allocated from: malloc [/vobs/ubtssw_brrm/test/test_build/linux-x86/rtlib.o] ...

.NET allocations profiling

I need a way to track all allocations in a .NET application that happen during a single step in the process of debugging my application. I mean, when I'm in the debugger, stepping through code, I would like to see for a single step what allocation took place. Is there a tool or a way to do it? I tried several memory profilers including C...

How to find number of memory accesses

Can anybody tell me a unix command that can be used to find the number of memory accesses that took place in a given interval. vmstat, top and sar only give the amount of physical memory space occupied/available .. But do not give the number of memory of accesses in a given interval ...

Creating huge images

My program has the feature to export a hi-res image of the working canvas to the disk. Users will frequently try to export images of about 20,000 x 10,000 pixels @ 32bpp which equals about 800MB. Add that to the serious memory consumption already going on in your average 3D CAD program and you'll pretty much guarantee an out-of-memory cr...

How do I use Loki's small object allocator?

I need to use Loki's small object allocator but I am very confused as to how it works. I've read the documentation and lots of forums but it doesnt make sense: some of them say to use the stl, others use custom allocators. I just need to be able to test its performance with allocating and deallocating objects of different sizes. Could so...

Malloc corrupting already malloc'd memory in C

I'm currently helping a friend debug a program of his, which includes linked lists. His list structure is pretty simple: typedef struct nodo{ int cantUnos; char* numBin; struct nodo* sig; }Nodo; We've got the following code snippet: void insNodo(Nodo** lista, char* auxBin, int auxCantUnos){ printf("*******Insertando\n"...

realloc returns NULL after some time while allocating small (<500Kb) data block; there is enoug memory

Hi! The short question is: what can be the problem? The overall memory usage of my program (shown by task manager) is almost the same all the time (near 40 minutes) it's running, and I have near 2G more free memory. Running on win2003r2. Memory allocation/freeing is high enough - I need to interact with other software, preparing dat...

Remove never-run call to templated function, get allocation error on run-time

I have a piece of templated code that is never run, but is compiled. When I remove it, another part of my program breaks. First off, I'm a bit at a loss as to how to ask this question. So I'm going to try throwing lots of information at the problem. Ok, so, I went to completely redesign my test project for my experimental core librar...

Please help with iPhone Memory & Images, memory usage crashing app

I have an issue with memory usage relating to images and I've searched the docs and watched the videos from cs193p and the iphone dev site on memory mgmt and performance. I've searched online and posted on forums, but I still can't figure it out. The app uses core data and simply lets the user associate text with a picture and stores t...

Starting a C++ project. Should I worry about freeing dynamic allocated memory?

I am pretty proficient with C, and freeing memory in C is a must. However, I'm starting my first C++ project, and I've heard some things about how you don't need to free memory, by using shared pointers and other things. Where should I read about this? Is this a valuable replacement for proper delete C++ functionality? How does it work...

c: memory allocation (what's going on)

Hi, everyone Please take a look at this piece of code. I'm allocating one byte for the first variable and another byte for the second one. However, it seems like the compiler allocates more (or I'm missing something). The program outputs both strings, even though their length is more the one byte. void main() { char* some1 = mallo...

Does reserving capacity incur two allocations or just one?

std::vector<T> vec; // line #1 vec.reserve(100); // line #2 I am wondering if line #1 triggers a small allocation (say, memory for 10 Ts), or if the first allocation happens on line #2. Does the standard say anything about that? ...

Which is G++ 4.4.1 default allocator?

I was wondering which is the default memory allocator in G++ 4.4.1, on Ubuntu 9.1. I am interested in comparing different C++ allocators in a multithreaded environment. And where can I get more information about the default memory allocator? EDIT: I refer to new and delete operators. The only linking is to rt and pthread Regards ...

Hoard allocator not "working"?

I'm trying to Hoard allocator to work, but it seems it doesn't. I have a benchmark application that does a lot of dynamic memory management. The execution time for Hoard and glibc memory manager is the same. It makes me wonder if I'm doing the right thing. What I do is... export LD_PRELOAD="/path/libhoard.so" g++ main.cpp -O3 -o bm -l...

Where I should call [object release] ?

Hello, I've subclassed some UITextField and added some custom properties. In a UITableViewController, in the ViewDiDLoad I init them, and in the cellForRowAtIndexPath I add them to the cell with [cell.contentView addSubview:customTextField]; Each cell has a different customTextField as all of them are very different. Where I should c...

Initial capacity of collection types, i.e. Dictionary, List

Certain collection types in .Net have an optional "Initial Capacity" constructor parameter. i.e. Dictionary<string, string> something = new Dictionary<string,string>(20); List<string> anything = new List<string>(50); I can't seem to find what the default initial capacity is for these objects on MSDN. If I know I will only be storin...

Silverlight 4 seems like starving of memory

I have been playing a bit with Silverlight and try to port my Silverlight 3.0 application to Silverlight 4.0. My application loads different XAP files and upon a user request create an instance of a Xaml user control and adds it to the main container, in a sort of MEF approach in order I can have an extensible and pluggable application....