Linux gcc cc1:内存不足

Linux gcc cc1:内存不足,linux,gcc,stack,ccl,Linux,Gcc,Stack,Ccl,我正在尝试用Angstrom Linux在BeagleBoard中编译源代码。 昨天我能够编译我的代码。但今天我无法编译代码,它说: ccl: out of memory allocating 268439608 bytes after a total of 405504 bytes make *** [getimagefromcam1.o] Error 1 我的编译字符串是: gcc getimagefromcam1.c `pkg-config --cflags --libs opencv`

我正在尝试用Angstrom Linux在BeagleBoard中编译源代码。 昨天我能够编译我的代码。但今天我无法编译代码,它说:

ccl: out of memory allocating 268439608 bytes after a total of 405504 bytes
make *** [getimagefromcam1.o] Error 1
我的编译字符串是:

gcc getimagefromcam1.c `pkg-config --cflags --libs opencv` -o getimagefromcam1 -lpthread
代码是:

#include <cv.h>
#include <highgui.h>
#include <cxcore.h>
#include <stdio.h>

int main(int argc, char* argv[])
{    
  CvCapture* camera = cvCreateCameraCapture(0); // Use the default camera

  IplImage*     frame = 0;
  IplImage      img;

  cvSetCaptureProperty(camera,CV_CAP_PROP_FRAME_WIDTH,2016) ;
  cvSetCaptureProperty(camera,CV_CAP_PROP_FRAME_HEIGHT,1512); 

  frame = cvQueryFrame(camera); //need to capture at least one extra frame
  frame = cvQueryFrame(camera);

  if (frame != NULL) {
    printf("got frame 1\n\r");
        cvSaveImage("webcam1.jpg", frame,0);
  } else {
      printf("Null frame 1\n\r");
  }

    frame = cvQueryFrame(camera); //need to capture at least one extra frame
  frame = cvQueryFrame(camera);

  if (frame != NULL) {
    printf("got frame 1\n\r");
        cvSaveImage("webcam1.jpg", frame,0);
  } else {
      printf("Null frame 1\n\r");
  }
  cvReleaseCapture(&camera);
  return 0;
}

我该怎么解决呢?

你的内存明显不足(
268439>221256
)。现在您有两个选择:

  • 创建一个类似这样的模型。归结起来是:

    su - root
    # for one GB of swap
    dd if=/dev/zero of=tmpswap bs=1024 count=1M
    mkswap tmpswap
    swapon tmpswap
    
    我会选择这种方式作为一种快速修复方法,更不用说你真的应该用少量内存进行一点交换

    阅读这篇文章,如果你想让这个改变永久化,它包含了一些关于权限和fstab的有价值的提示

  • 尽量简化代码,使
    cc1
    不需要太多内存。但我不知道该怎么做


  • 您使用的是什么版本的
    gcc
    ?尝试升级到最新版本(例如4.7或至少4.6)。问题已经解决,但我在这里看到了一个新错误:尝试访问超出设备端的mmcblk0p2:rw=0,want=34359738368,limit=15433728尝试访问超出设备端的mmcblk0p2:rw=0,want=34359738368,limit=15433728听起来不太好,但是我不知道帽子是从哪里来的。我建议使用fallocate而不是dd,因为它的速度要快得多:
    fallocate-l 1G tmpswap
    @askvictor哦,很好,我不知道。我知道
    truncate
    不起作用,因为它创建了
    swapon
    不喜欢的稀疏文件(可以理解)。将进行编辑。有关fallocate的建议不正确:
    su - root
    # for one GB of swap
    dd if=/dev/zero of=tmpswap bs=1024 count=1M
    mkswap tmpswap
    swapon tmpswap