gpt4 book ai didi

c++ - 如何放大 'free memory'

转载 作者:行者123 更新时间:2023-11-30 04:43:03 24 4
gpt4 key购买 nike

我使用colcon工具构建fastRTPS源码,在构建过程中,终端会卡在那里,最后输出一些错误信息。

在构建代码之前,在一个终端中,我使用命令 'free -m' 来检查内存信息,当列 'free memory' 的值减少到非常小的时候。执行构建命令的另一个终端将卡在那里。应该是内存不够用,怎么解决?

Before build code:
total used free shared buff/cache available
Mem: 912 124 700 4 87 768
Swap: 0 0 0

The last time ‘free -m’ was executed:
total used free shared buff/cache available
Mem: 912 820 4 4 87 72
Swap: 0 0 0
  • 一个终端错误信息:
ubuntu@raspberrypi:~/ros2_ws/src/eProsima/Fast-RTPS$ colcon build
Starting >>> fastrtps
[Processing: fastrtps]
[Processing: fastrtps]
[Processing: fastrtps]
[Processing: fastrtps]
[Processing: fastrtps]
--- stderr: fastrtps
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
make[2]: *** [src/cpp/CMakeFiles/fastrtps.dir/rtps/writer/StatefulWriter.cpp.o] Error 4
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [src/cpp/CMakeFiles/fastrtps.dir/all] Error 2
make: *** [all] Error 2
---
Failed <<< fastrtps [ Exited with code 2 ]
  • 其他终端报错信息:
[76834.368716]Out of memory: Kill process 21298(cclplus) score 233 or sacrifice child
[76834.406051]Killed process 21298(cclplus) total-vm:251188KB, anon-rss:217952KB, file-rss:0KB, shmem-rss:0KB

最佳答案

  1. 您可以随时重新启动构建过程并最终完成它。
  2. make[2]: *** Waiting for unfinished jobs....听起来你正在运行几个编译过程,尝试禁用它,删除 -j N来自 make命令,只留下一个编译线程。
  3. 获取内存为 4Gb 的 Pi4

启用 swap 没有帮助,你只是没有足够的内存,使用 swap 会让它爬行 20 分钟然后死掉,而不是死掉然后重新启动。


好的,回答评论中的一些问题。我不仅在看到 *** waiting for unfinished jobs 时怀疑并行编译,而且当我看到:

Starting >>> fastrtps
[Processing: fastrtps]
[Processing: fastrtps]
[Processing: fastrtps]
[Processing: fastrtps]
[Processing: fastrtps]

请检查您使用的构建系统,如何将并行编译限制为单个进程。

关于c++ - 如何放大 'free memory',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58480705/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com