对于高容量记录器应用程序使用什么分配方法?
我正在使用 Delphi 开发记录器/嗅探器。在操作过程中,我会获取大量数据,这些数据在压力操作期间会累积到大约 3 GB 的数据。 在某些计算机上,当我们达到这些级别时,应用程序将停止运行,有时会引发异常。
目前我正在使用 GetMem 函数来分配指向每条消息的指针。
有没有更好的方法来分配内存,以便最大限度地减少失败的机会?请记住,我无法将大小限制为硬性限制。
您对使用 HeapAlloc、VirtualAlloc 甚至映射文件有何看法?哪个会更好?
谢谢。
I'm developing a logger/sniffer using Delphi. During operation I get hugh amounts of data, that can accumulate during stress operations to around 3 GB of data.
On certain computers when we get to those levels the application stops functioning and sometimes throws exceptions.
Currently I'm using GetMem function to allocate the pointer to each message.
Is there a better way to allocate the memory so I could minimize the chances for failure? Keep in mind that I can't limit the size to a hard limit.
What do you think about using HeapAlloc, VirtualAlloc or maybe even mapped files? Which would be better?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的根本问题是 32 位进程的 4GB 硬地址空间限制。由于您在 3GB 时遇到问题,我只能假设您正在使用在 64 位 Windows 或 32 位 Windows 上运行的
/LARGEADDRESSAWARE
以及 /3GB 启动开关。我认为您有几个选择,包括但不限于以下内容:
我无法就解决方案给出明确的建议,因为我不了解您的架构,但根据我的经验,减少内存占用通常是最好的解决方案。
使用不同的分配器可能没有什么区别。是的,确实有低碎片分配器,但它们肯定不会真正解决您的问题。他们所能做的就是稍微降低这种情况发生的可能性。
Your fundamental problem is the hard address space limit of 4GB for 32 bit processes. Since you are hitting problems at 3GB I can only presume that you are using
/LARGEADDRESSAWARE
running on 64 bit Windows or 32 bit Windows with the /3GB boot switch.I think you have a few options, including but not limited to the following:
I can't advise definitively on a solution since I don't know your architecture but in my experience, reducing your memory footprint is often the best solution.
Using a different allocator is likely to make little difference. Yes it is true that there are low-fragmentation allocators but they surely won't really solve your problem. All they could do would be make it slightly less likely to arise.