简体   繁体   English

Windows限制中的共享内存(C ++)

[英]shared memory in windows limits (c++)

Currently I'm working on a solution for the memory limits per process. 目前,我正在为每个进程的内存限制制定解决方案。 So I came to shared memory. 所以我来到了共享记忆。 First, I'm using windows 7 with visual studio as developer platform, the software will run on a modern windows server system with multiple CPU's and a huge memory. 首先,我将Windows 7与Visual Studio用作开发人员平台,该软件将在具有多个CPU和巨大内存的现代Windows服务器系统上运行。

Well, I informed my self about memory limits per process, and I need to access much more memory. 好吧,我告知自己每个进程的内存限制,并且我需要访问更多的内存。 So my idea was creating multiple processes and use shared memory. 所以我的想法是创建多个进程并使用共享内存。

But is it really good to create a lot shared memory? 但是创建很多共享内存真的很好吗? And what about performance? 那性能呢?

Well, I informed my self about memory limits per process, and I need to access much more memory. 好吧,我告知自己每个进程的内存限制,并且我需要访问更多的内存。 So my idea was creating multiple processes and use shared memory. 所以我的想法是创建多个进程并使用共享内存。

The limits on memory per process are for virtual memory . 每个进程对内存的限制是针对虚拟内存的 This basically means that your address space has a maximum size (eg 4 gigabytes on a system with 32-bit pointers). 这基本上意味着您的地址空间具有最大大小(例如,在具有32位指针的系统上为4 GB)。 Since shared memory is a mapping of memory into your address space, there's no way that would get you out of the problem you have. 由于共享内存是内存到地址空间的映射,因此没有任何办法可以使您摆脱困境。

Keep in mind that if you distribute the memory blocks into multiple processes, you'll eventually reach the limits of physical memory and then system performance will slow to a crawl. 请记住,如果将内存块分配到多个进程中,最终将达到物理内存的极限,然后系统性能将下降。

If you really need more memory than your system can grant you, you need to start to persist your data to disk. 如果您确实需要更多的内存,而不是系统可以分配给您的内存,则需要开始将数据持久保存到磁盘。 Memory mapped files can allow you to quickly swap memory blocks in and out of your address space. 内存映射文件可以使您快速在地址空间内外交换内存块。

@ Aurus, @ Aurus,

It sounds as though what you require to cover your targets is a custom-engineered solution tailored to specific (albeit under-described) requirements. 听起来您需要满足的目标是针对特定(尽管描述不足)需求量身定制的定制解决方案。 While Stack Overflow is extremely useful for developers and software engineers seeking professional clarity and programmatic examples, whatever applicable high-level engineering is available within may not be easy to locate and will likely not provide the specific answers you seek. 虽然Stack Overflow对于寻求专业知识和程序示例的开发人员和软件工程师非常有用,但是其中可用的任何适用高级工程可能都不容易找到,也可能无法提供您所寻求的特定答案。 One could make too many assumptions from your post. 一个人可能从您的帖子中做出太多假设。

Whatever benefit(s) you may (or may not) attain from staggering quantities of RAM and or multiple threads on multiple processors would best be left to those with hard experience building such systems. 无论利益(S),你可能(也可能不会)从RAM和或在多个处理器上的多个线程数量惊人会达到最好留给那些有经验的艰苦建设这样的系统。 I have years in the field myself and can confidently express that I myself lack that specific experience. 我本人在该领域有多年经验,可以自信地表示自己缺乏这种特定经验。 Honestly I hope to avoid that eventuality because high-dollar hardware commonly attends high-pressure schedules, and those can lead to other issues as well. 老实说,我希望避免这种情况发生,因为高美元的硬件通常会参加高压计划,而这些计划也会导致其他问题。 I'll speculate a tiny bit though -- if only because it costs you nothing... 我会推测一点点-仅仅是因为它不花钱...

If your intent is firmly fixed upon utilizing Windows platforms my first-order guess is: 如果您的意图坚定地利用Windows平台,那么我的一阶猜测是:

  • a clustered server environment (many multi-core processors for crunching high numbers of threads, backed by a massive quantity of available RAM) 集群服务器环境(许多用于处理大量线程的多核处理器,并由大量可用RAM提供支持)
  • cutting edge drive hardware -- if you're seeking to minimize the impact of frequent virtual memory access you'll likely need to target specific cutting-edge hardware options that enable you to literally replace spindle-drives with more eloquent DRAM sticks, that is to say solid state drives -- not the trivial type you commonly find in modern iPods and mobile PDAs... I refer to the real deal -- classic solid state drives [ one fine example is here -- look under hardware]. 尖端驱动器硬件-如果您想最大程度地减少频繁访问虚拟内存的影响,则可能需要针对特定​​的尖端硬件选件,这些选件使您能够用更加雄辩的DRAM棒来替换主轴驱动器,即说固态驱动器-而不是您在现代iPod和移动PDA中常见的普通类型...我指的是真正的交易 -经典固态驱动器[ 这里是一个很好的例子 -在硬件下查看]。 Their products are two to three orders of magnitude faster than spindle drives and even far faster than consumer solid state as well (albeit not cheap). 他们的产品比主轴驱动器快两到三个数量级,甚至比消费者固态产品快得多(尽管不便宜)。

Your goals appear to indicate that cost isn't a great concern, but that's about as good as I can give you while lacking more specific information. 您的目标似乎表明,花费不是什么大问题,但这在我没有更多具体信息的情况下可以提供给您。

One final bit of advice though, when seeking help from engineers it's best to tell them exactly what you seek to accomplish (the goal(s)). 最后一点建议是,在寻求工程师帮助时,最好准确地告诉他们您要实现的目标(目标)。 Allow them to provide the options and match the limitations of reality and modern technology to your dilemma as well as your financial targets. 让他们提供选择,使现实和现代技术的局限性适合您的困境和财务目标。 More often than not, even with esoteric and eccentric requirements, the best solution is actually a custom 'outside-the-box' engineering solution that also ends up being far cheaper to build / implement than a brute-force approach. 即使有深奥而古怪的要求,通常最好的解决方案实际上是定制的“开箱即用”的工程解决方案,该解决方案的最终构建/实施成本要比蛮力方法便宜得多。 To put it another way, help the engineers to help you while noting that the GIGO Principle applies as well. 换句话说,请帮助工程师帮助您,同时注意GIGO原则也适用。

I sincerely hope something I provided is useful. 我衷心希望我提供的东西有用。 Good luck. 祝好运。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM