allocation

Is it possible to track allocation/deallocation in C#?

As far as I can tell, this is isn't possible, so I'm really just hoping for a left field undocumented allocation hook function. I want a way to track allocations like in _CrtSetAllocHook, but for C#/.net. The only visibility to the garbage collector/allocation appears to be GC.CollectionCount. Anyone have any other .net memory mojo? ...

Uninitialized memory blocks in VC++

As everyone* knows, the Visual C++ runtime marks uninitialized or just freed memory blocks with special non-zero markers. Is there any way to disable this behavior entirely without manually setting all uninitialized memory to zeros? It's causing havoc with my valid not null checks, since 0xFEEEFEEE != 0. Hrm, perhaps I should explain a ...

Multithreaded Memory Allocators for C/C++

Hi I currently have heavily multithreaded server application, and I'm shopping around for a good multithreaded memory allocator. So far I'm torn between: -Sun's umem -Google's tcmalloc -Intel's threading building blocks allocator -Emery Berger's hoard From what I've found hoard might be the fastest, but I hadn't heard of it before ...

What's a good C memory allocator for embedded systems?

I have an single threaded, embedded application that allocates and deallocates lots and lots of small blocks (32-64b). The perfect scenario for a cache based allocator. And although I could TRY to write one it'll likely be a waste of time, and not as well tested and tuned as some solution that's already been on the front lines. So what ...

Would NTFS allocation blocks of 16KB or 32KB make compile time faster in comparison to the default 4KB?

Would NTFS allocation blocks of 16KB or 32KB make compile time faster in comparison to the default 4KB? ...

Simple efficiency question C++ (memory allocation)..and maybe some collision detection help?

I'm writing a little arcade-like game in C++ (a multidirectional 2d space shooter) and I'm finishing up the collision detection part. Here's how I organized it (I just made it up so it might be a shitty system): Every ship is composed of circular components - the amount of components in each ship is sort of arbitrary (more components, ...

C++ Multi-dimensional Arrays on the Heap

I went looking for this the other day, and thought it should probably be added to StackOverflow's reservoir of questions. How would I go about dynamically allocating a multi-dimensional array? ...

Proper Memory allocation

I have the following construction: typedef struct bucket { char *key; ENTRY *data; struct bucket *next; } bucket; typedef struct { size_t size; bucket **table; } hash_table; But I have no idea how to allocate memory for that. I tried: hash_table* ht = malloc(sizeof(hash_table)*101); in order to create a hashta...

Wrapping unmanaged c++ in a managed wrapper

I have an unmanaged C++ library. I would like to expose the functionality for .NET applications. There's one partucular function I am not sure how to handle: typedef void (free_fn*) (void*); void put (void *data, free_fn deallocation_function); The idea is that you pass dynamically allocated buffer to the function and supply a dealloca...

Why doesn't this C++ STL allocator allocate?

I'm trying to write a custom STL allocator that is derived from std::allocator, but somehow all calls to allocate() go to the base class. I have narrowed it down to this code: template <typename T> class a : public std::allocator<T> { public: T* allocate(size_t n, const void* hint = 0) const { cout << "yo!"; return 0...

Getting a stack overflow exception when declaring a large array

The following code is generating a stack overflow error for me int main(int argc, char* argv[]) { int sieve[2000000]; return 0; } How do I get around this? I am using Turbo C++ but would like to keep my code in C EDIT: Thanks for the advice. The code above was only for example, I actually declare the array in a function and...

How to alloc a dynamic typed object in objective-c

Hi, I have seen a lot of talk about dynamic typing in objective-c. But i haven't seen any examples of what i think it is supposed to be. lets say I have a generic function that is supposed to juggle two objects (one gets allocated and the other gets freed) and the calling object attaches it self to the newly alloced object. Both are in...

C# data allocation problem

Hello, I have the following problem. I have a C++ dll, containing the function void cpp_send (void *data_, size_t size_, free_fn *ffn_) { //sends data } then I have C# dll that has a class public class CS_dll : IDisposable { void cs_send (void *data) { IntPtr ptr = Marshal.AllocHGlobal (data.Length); Marshal...

std::allocator construct/destroy vs. placement new/p->~T()

For a project of mine, I am writing some STL containers from scratch (I have my reasons). Since I am mimicking the functionality and interfaces of the STL so closely I am doing my best to keep with the policy "if it has the same name as a standard construct, it will conform to the standard as much as possible." So, of course my containe...

MSSQL Cursor for huge tables cannot allocate space

We are trying to set up a cursor to run through records generated from a join between two 'instances' of the same huge table (more than 150 M records). The following exception message comes out: Could not allocate space for object 'dbo.SORT temporary run storage: 165282123350016' in database 'tempdb' because the 'PRIMARY' filegroup...

What are some good tools for measuring memory allocations on Windows?

I have an application that keeps using up more and more memory as time goes by (while actively running), but there are no leaks. So I know the program isn't doing something totally wrong, which would be easy to find. Instead I want to track allocations so I can start tracking down the issue, and on a Mac I'd use Instruments, which gives...

Issues with C++ 'new' operator?

I've recently come across this rant. I don't quite understand a few of the points mentioned in the article: The author mentions the small annoyance of delete vs delete[], but seems to argue that it is actually necessary (for the compiler), without ever offering a solution. Did I miss something? In the section 'Specialized allocators',...

Is there an alternative way to free dynamically allocated memory in C - not using the free() function?

I am studying for a test, and I was wondering if any of these are equivalent to free(ptr): malloc(NULL); calloc(ptr); realloc(NULL, ptr); calloc(ptr, 0); realloc(ptr, 0); From what I understand, none of these will work because the free() function actually tells C that the memory after ptr is available again for it to use....

To "new" or not to "new"

Is there a rule of thumb to follow when to use the new keyword and when not to when declaring objects? List<MyCustomClass> listCustClass = GetList(); OR List<MyCustomClass> listCustClass = new List<MyCustomClass>(); listCustClass = GetList(); ...

Escape analysis in Java

As far as I know the JVM uses escape analysis for some performance optimisations like lock coarsening and lock elision. I'm interested if there is a possibility for the JVM to decide that any particular object can be allocated on stack using escape analysis. Some resources make me think that I am right. Is there JVMs that actually do it...