Android cannot allocate memory

本文介绍了解决在编译Android系统代码时遇到的内存溢出问题的方法。通过创建和配置交换文件来增加虚拟内存,有效缓解了编译过程中的内存压力。

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

转载:https://blog.youkuaiyun.com/ds1130071727/article/details/68927734


之前git上切分支编译android代码时,虚拟机总是出现cannot allocate memory问题,后来整理了下解决方法:

1.创建swapfile文件
下面的代码是创建一个1G的swapfile,如果想要512M,将bs将为1024
sudo dd if=/dev/zero of=/swapfile bs=2048 count=524288
ls -lh /swapfile   //查看是否创建成功

2.设置交换区
sudo mkswap /swapfile

3.启动系统交换区
sudo swapon /swapfile  

如果以上方法不能解决问题,那就只有make clean,全编了。Android系统代码复杂,建议大家好好管理代码。

[libwebp encoder @ 0x1d463c0] WebPAnimEncoderAssemble() failed with error: 1 [vost#5:0/libwebp_anim @ 0x1d45240] [enc:libwebp_anim @ 0x1d45f00] Error submitting video frame to the encoder [vost#5:0/libwebp_anim @ 0x1d45240] [enc:libwebp_anim @ 0x1d45f00] Error flushing encoder: Cannot allocate memory [vost#5:0/libwebp_anim @ 0x1d45240] Task finished with error code: -12 (Cannot allocate memory) [vost#5:0/libwebp_anim @ 0x1d45240] Terminating thread with return code -12 (Cannot allocate memory) Output #7, webp, to '/mnt/data/encoded/snapshots/1944067372482666498/008.webp': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf62.0.100 Stream #7:0(und): Video: webp, yuv420p(progressive), 856x456 [SAR 1:1 DAR 107:57], q=2-31, 200 kb/s, 24 fps, 1k tbn (default) Metadata: encoder : Lavc62.0.101 libwebp_anim handler_name : VideoHandler vendor_id : [0][0][0][0] [libwebp encoder @ 0x1d4eec0] WebPAnimEncoderAssemble() failed with error: 1 [vost#7:0/libwebp_anim @ 0x1d4e140] [enc:libwebp_anim @ 0x1d4a2c0] Error submitting video frame to the encoder [vost#7:0/libwebp_anim @ 0x1d4e140] [enc:libwebp_anim @ 0x1d4a2c0] Error flushing encoder: Cannot allocate memory [vost#7:0/libwebp_anim @ 0x1d4e140] Task finished with error code: -12 (Cannot allocate memory) [vost#7:0/libwebp_anim @ 0x1d4e140] Terminating thread with return code -12 (Cannot allocate memory) [out#0/webp @ 0x19a8280] video:12KiB audio:0KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: 0.000000% [out#1/webp @ 0x1bdd040] video:34KiB audio:0KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: 0.000000% [out#2/webp @ 0x1bdef80] video:17KiB audio:0KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: 0.000000% [out#3/webp @ 0x1d3a900] video:17KiB audio:0KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: 0.000000% [out#4/webp @ 0x1d3fa80] video:11KiB audio:0KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: 0.000000% [out#5/webp @ 0x1d44480] video:0KiB audio:0KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: unknown [out#5/webp @ 0x1d44480] Output file is empty, nothing was encoded(check -ss / -t / -frames parameters if used) [out#6/webp @ 0x1d48cc0] video:0KiB audio:0KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: unknown [out#6/webp @ 0x1d48cc0] Output file is empty, nothing was encoded(check -ss / -t / -frames parameters if used) [out#7/webp @ 0x1d4d180] video:0KiB audio:0KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: unknown [out#7/webp @ 0x1d4d180] Output file is empty, nothing was encoded(check -ss / -t / -frames parameters if used) frame= 1 fps=0.0 q=-0.0 Lq=-0.0 q=-0.0 q=-0.0 q=-0.0 q=0.0 q=0.0 q=0.0 size= 12KiB time=N/A bitrate=N/A speed=N/A
最新发布
07-16
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值