简体   繁体   English

python 3.7 如何分配堆 memory

[英]How python 3.7 allocate heap memory

I'm having issues in K8s with memory allocation.我在使用 memory 分配的 K8s 中遇到问题。 Pod gets killed by OMM Killer, because of strictly defined limits, let's say 1GB. Pod 被 OMM Killer 杀死,因为严格定义的限制,比如说 1GB。

How python 3.7 (python memory manager) allocates memory? python 3.7(python memory manager)如何分配memory? From the pod memory graph I can assume that it allocates double amount of memory for heap.从 pod memory 图中,我可以假设它为堆分配了双倍数量的 memory。

Linux: Linux:

You can limit the used resources from inside your program - not sure if it helps you though:您可以从程序内部限制使用的资源 - 但不确定它是否对您有帮助:

  • resources.setrlimit 资源.setrlimit

    Sets new limits of consumption of resource.设置资源消耗的新限制。 The limits argument must be a tuple (soft, hard) of two integers describing the new limits.限制参数必须是描述新限制的两个整数的元组(软,硬)。 A value of RLIM_INFINITY can be used to request a limit that is unlimited. RLIM_INFINITY 值可用于请求无限制的限制。

For windows this might help: Limit python script RAM usage in Windows对于 windows 这可能会有所帮助: 在 Windows 中限制 python 脚本 RAM 使用

Edit: Post for limiting under linux: Limit RAM usage to python program编辑:在 linux 下限制的帖子: 将 RAM 使用限制为 python 程序

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

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