提高::进程间:: managed_shared_memory:成长():内存重复使用? [英] boost::interprocess::managed_shared_memory: Grow(): Memory Reused?

查看:1062
本文介绍了提高::进程间:: managed_shared_memory:成长():内存重复使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用boost ::进程间:: managed_shared_memory。起初我分配例如x兆内存。当过程耗尽了内存,我们通过发展一个固定值内存(比如Y MB,执行unmap->成长() - >图)

I am using boost::interprocess::managed_shared_memory. Initially I allocate say X mb memory. When process ran out of memory, we grow the memory by a fixed value (say Y mb, perform unmap-> grow()-> map)

在成长,如果连续内存不可再用X + Y MB一个新块分配一个不同的基址。恰巧previously分配带宽X MB块怎么办?是否需要提振其删除,因为它已经映射的,没有过程是指它的照顾?

While growing, if contiguous memory is not available then a new chunk with X+Y mb is allocated with a different base address. What happens to previously allocated X mb chunk? Does boost take care of deleting it since it is already unmapped and no process is referring to it?

推荐答案

共享内存是一个平台特定的服务。

Shared memory is a platform specific service.

共享内存顾名思义是虚拟的。

Shared memory is by definition virtual.

最重要的是的不是从程序堆中分配的。共享内存的映射到进程空间的由OS。

Most of all is not allocated from the program heap. Shared memory is mapped into the process space by the OS.

通过以​​上所有的


  • 它的平台定义的内存是否被重新使用(再利用这里将仅仅意味着无论是在内存中当时的页面保持不变;如果地址发生变化时,这意味着什么在现实中,因为它只是得到相同的页面重新映射到不同的虚拟的过程空间地址)。

  • it's platform defined whether the memory is reused (reuse here would simply mean whether the pages that are in-memory at the time are kept; if the address is changed, this means nothing in reality, because it's just the same pages getting remapped to a different virtual address in process space).

在换句话说(因为你已经在半场暗示),后内存未映射,提振无关删除 的,因为没有从堆在第一个地方是有史以来分配的。

In other words (as you already half-hinted at), after the memory is unmapped, boost has nothing to delete, because nothing was ever allocated from the heap in the first place.

这篇关于提高::进程间:: managed_shared_memory:成长():内存重复使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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