Google lmctfy 3.2 - Example allocate memory in container

本文深入探讨了memoryisolation的概念及其在Linux系统中的实现方式,特别是如何通过启用CONFIG_MEMCG来实现资源隔离,确保内存使用合理且避免资源争抢问题。文章还提供了实践案例和具体配置步骤,帮助开发者正确理解和利用这一特性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

写个了小程序试着在memory_only下分配超过100MB的内存,结果每次都能成功,百思不得其姐,岂不是违背了资源隔离的本意?

原来是这个原因,

"Looks like I didn't have memory isolation enabled.  I needed to enable 
CONFIG_MEMCG, and now things work (without the symlinks).  For 
reference, here's my full kernel config "

https://groups.google.com/forum/#!topic/lmctfy/GKzhuElgq2A

https://wiki.gentoo.org/wiki/Lmctfy


简单的了解了一下memory isolation,其实是Memory Resource Controller for Control Groups,具体内容参考

https://www.kernel.org/doc/Documentation/cgroups/memory.txt


a. Isolate an application or a group of applications
   Memory-hungry applications can be isolated and limited to a smaller
   amount of memory.
b. Create a cgroup with a limited amount of memory; this can be used
   as a good alternative to booting with mem=XXXX.
c. Virtualization solutions can control the amount of memory they want
   to assign to a virtual machine instance.
d. A CD/DVD burner could control the amount of memory used by the
   rest of the system to ensure that burning does not fail due to lack
   of available memory.
e. There are several other use cases; find one or use the controller just
   for fun (to learn and hack on the VM subsystem).




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值