对于高容量记录器应用程序使用什么分配方法?

发布于 2024-12-04 08:03:57 字数 272 浏览 2 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你没皮卡萌 2024-12-11 08:03:57

您的根本问题是 32 位进程的 4GB 硬地址空间限制。由于您在 3GB 时遇到问题,我只能假设您正在使用在 64 位 Windows 或 32 位 Windows 上运行的 /LARGEADDRESSAWARE 以及 /3GB 启动开关。

我认为您有几个选择,包括但不限于以下内容:

  1. 使用更少的内存。也许您可以以较小的块进行处理或将一些内存推送到磁盘。
  2. 使用 64 位 Delphi(刚刚发布)或 FreePascal。这使您摆脱了地址空间限制,但将您限制为 64 位版本的 Windows。
  3. 使用内存映射文件。在具有大量内存的计算机上,这是访问操作系统内存缓存的一种方法。内存映射文件不适合胆小的人。

我无法就解决方案给出明确的建议,因为我不了解您的架构,但根据我的经验,减少内存占用通常是最好的解决方案。

使用不同的分配器可能没有什么区别。是的,确实有低碎片分配器,但它们肯定不会真正解决您的问题。他们所能做的就是稍微降低这种情况发生的可能性。

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:

  1. Use less memory. Perhaps you can process in smaller chunks or push some of the memory to disk.
  2. Use 64 bit Delphi (just released) or FreePascal. This relieves you of the address space constraint but constrains you to 64 bit versions of Windows.
  3. Use memory mapped files. On a machine with a lot of memory this is a way of getting access to the OS memory cache. Memory mapped files are not for the faint hearted.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文