即使有足够的内存,realloc / HeapRealloc也会失败 [英] realloc/HeapRealloc fails eventhough enough memory is available

查看:240
本文介绍了即使有足够的内存,realloc / HeapRealloc也会失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的机器具有8GB的RAM,并且正在运行Windows Server2008。当我的应用程序已分配1.5〜1.7GB时, malloc / realloc()无法分配更多的内存。我尝试改用 HeapAlloc / HeapRealloc ,同样的情况也会发生。

My machine has 8GB of RAM and is running Windows Server 2008. malloc/realloc() fails to allocate more memory when my application has 1.5~1.7GB already allocated. I tried switching to HeapAlloc/HeapRealloc instead and the same situation happens.

这里是否缺少我的东西?是什么原因导致当有明显可用的RAM时,我的应用程序无法分配更多的内存?

Is there something I am missing here? What could be causing my application to be unable to allocate more memory when there is clearly available RAM?

推荐答案


当有明显可用的RAM时,是什么导致我的应用程序无法分配更多的内存?

What could be causing my application to be unable to allocate more memory when there is clearly available RAM?

堆碎片 。分配不只是要求内存。它要求一块连续的内存。

Heap fragmentation. Allocation doesn't simply ask for memory. It asks for a contiguous piece of memory.

当然,鉴于您提供的数据稀疏( 多少 ,这是 32位还是64bit 应用?),还可能存在其他问题。

Of course, given the sparse data you provided (how much are you trying to re-alloc when that happens? is this a 32bit or a 64bit app?), there could be other problems as well.

这篇关于即使有足够的内存,realloc / HeapRealloc也会失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆