SIGKILL同时在C ++中分配内存 [英] SIGKILL while allocating memory in C++
问题描述
我正在用C ++开发具有有限内存的嵌入式系统(Tegra 2)的应用程序。我在处理整个代码中的 new
和 NULL结果,但有时会发生,但应用程序能够处理这。
问题是,如果内存用完了,系统会通过SIGKILL杀死进程。我可以以某种方式告诉 new
应该只返回NULL,而不是杀死进程?
我不知道你使用什么样的操作系统,但你应该检查 如果它是一个服务器管理/可能会发生以下情况: 解决方案:禁用内存过量使用: I'm developing application for an embedded system with limited memory (Tegra 2) in C++. I'm handling NULL results of The problem is that the system kills the process by SIGKILL if the memory runs out completely. Can I somehow tell that I am not sure what kind of OS You are using, but You should check if
it supports opportunistic memory allocation like Linux does. If it is enabled, the following may happen: Solution: Disable overcommitting of memory:
这篇关于SIGKILL同时在C ++中分配内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
是否支持
新
或 malloc
从内核获取有效的地址。 即使没有足够的内存,因为...
echo 2> / proc / sys / vm / overcommit_memory
new
and new[]
throughout the code which sometimes occurs but application is able to handle this.new
should just return NULL instead of killing the process?
new
or malloc
gets a valid address from the kernel. Even if there is not enough memory, because ...
echo 2 > /proc/sys/vm/overcommit_memory