RbG
RbG

Reputation: 3203

What is MemAlloc in C? How does it differ from malloc?

I have faced this question many times, but I have no idea about it. I searched many sites. The information I gathered is:

MemAlloc is a free memory allocation tool. It allows you to stress and test your Windows operating system by requesting any amount of memory you want.

void * Memalloc(ulong size,int flags);

Allocates memory in the context of OllyDbg. Requests are redirected to GlobalAlloc(). Use it to allocate larger chunks of memory. Call Memfree() to free this memory.`

These information doesn't answer a my queries, and the concept is still not very clear to me. It will be kind of you if you describe the purpose of memalloc.

I have another question: if it is memory allocation tool what is the difference between malloc vs memalloc?

Upvotes: 1

Views: 13612

Answers (2)

Asaf
Asaf

Reputation: 4407

The answer is that malloc is part of the C standard library and exists for any C compiler/tool chain, whereas MemAlloc is not part of the C standard.

Apparently, according to the quotations you give, there are certain libraries that provide a function which is called MemAlloc, and which I guess allocates memory with some additional functionality (you'll need to read the documentation for each library to know the exact difference). This function itself might even use malloc.

Upvotes: 2

bkausbk
bkausbk

Reputation: 2790

OllyDbg is a 32-bit assembler level analysing debugger for Microsoft® Windows®. Emphasis on binary code analysis makes it particularly useful in cases where source is unavailable.

This is a debug library that contains memory allocation methods like Memalloc which is able to detect memory leaks. Memalloc looks for me like a wrapper over Windows GlobalAlloc.

So what is the difference to malloc? It is unknown, however it seems to me not being so fast as most malloc implementations can do since it uses relative outdated GlobalAlloc whereas most malloc implementations allocates large chunks with VirtualAlloc.

See what MSDN says about GlobalAlloc:

Note The global functions have greater overhead and provide fewer features than other memory management functions. New applications should use the heap functions unless documentation states that a global function should be used. For more information, see Global and Local Functions.

Upvotes: 4

Related Questions