c - C 中的 MemAlloc 是什么?它与 malloc 有何不同?

标签 c memory-management

我遇到过很多次这个问题,但我对此一无所知。我搜索了很多网站。我收集到的信息是:

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.`

这些信息没有回答我的疑问,我对这个概念还不是很清楚。如果您描述一下 memalloc 的用途,那将是您的荣幸。

我还有一个问题:如果是内存分配工具,malloc 和 memalloc 有什么区别?

最佳答案

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.

这是一个包含内存分配方法的调试库,例如 Memalloc,它能够检测内存泄漏。 Memalloc 对我来说就像是 Windows GlobalAlloc 上的包装器。

那么 malloc 有什么区别呢?它是未知的,但在我看来它不像大多数 malloc 实现那样快,因为它使用相对过时的 GlobalAlloc 而大多数 malloc 实现使用 VirtualAlloc 分配大块。

看看 MSDN 对 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.

关于c - C 中的 MemAlloc 是什么?它与 malloc 有何不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18758425/

相关文章:

c - 将函数传递给 C 中的另一个函数。我做错了什么?

C 编程 - 乐透模拟

linux - 缓冲区/缓存使用 100% 内存

objective-c - bool ? : operation syntax

C 程序无法正常运行

c - 在 C : I want to take a mix of characters and convert them to lower case

c++ - 为什么我们可以将可选参数传递给新表达式而不是删除表达式?

iphone - 保留/复制自动释放的对象

c++ - 堆栈内存是连续的吗?

c++ - 将对象传递给期望 shared_ptr 的函数而不实际共享所有权