完全托管的共享内存.NET 实现?

发布于 2024-10-10 05:07:48 字数 1540 浏览 0 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

樱花坊 2024-10-17 05:07:48

嗯,.NET框架是免费的,推荐。 .NET 4.0 支持 System.IO.MemoryMappedFiles 命名空间类。共享内存与垃圾收集器的概念存在相当大的阻抗不匹配,这就是为什么它需要一段时间。除非使用指针,否则从 GC 堆复制到 MMF 视图是不可避免的。

其他 IPC 机制也使用共享内存,只是它不是明确的,因为它内置于内核中。这一切都以大致相同的速度运行,一微秒来设置映射,然后仅使用总线带宽来进行内存到内存的复制。每秒 5 GB 是您遇到的最慢速度。

Well, the .NET framework is free, recommended. .NET 4.0 supports the System.IO.MemoryMappedFiles namespace classes. Shared memory is a fairly drastic impedance mismatch with the notion of a garbage collector, that's why it took a while. Unless you use pointers, copying from the GC heap to the MMF view is inevitable.

The other IPC mechanisms use shared memory too, it just isn't explicit since its built into the kernel. This all runs at roughly the same speed, a microsecond to setup the mapping and then just the bus bandwidth to do the memory-to-memory copy. Five gigabytes per second is the slowest you'll run into.

对你而言 2024-10-17 05:07:48

听起来您正在寻找 内存映射文件,这些文件受支持.NET 4.0 BCL。

从 .NET Framework 版本 4 开始,您可以使用托管代码来访问内存映射文件,就像本机 Windows 函数访问内存映射文件一样,如 MSDN 中的在 Win32 中管理内存映射文件中所述。图书馆

Sounds like you are looking for Memory-Mapped Files, which are supported in the .NET 4.0 BCL.

Starting with the .NET Framework version 4, you can use managed code to access memory-mapped files in the same way that native Windows functions access memory-mapped files, as described in Managing Memory-Mapped Files in Win32 in the MSDN Library

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