Gcc cc1: memory allocation

I am trying to compile the source code in my BeagleBoard with Angstrom Linux. Yesterday I was able to compile my code. But today I can’t compile the code, and it says:

ccl: out of memory allocating 268439608 bytes after a total of 405504 bytes make *** [getimagefromcam1.o] Error 1 

My compilation line:

 gcc getimagefromcam1.c `pkg-config --cflags --libs opencv` -o getimagefromcam1 -lpthread 

The code:

 #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; } 

when I write "free" says

  total used free shared buffers cached Mem: 241260 221256 20004 0 13748 116184 -/+ buffers/cache: 91324 149936 Swap: 0 0 0 

How can I solve it?

+4
source share
1 answer

There you are stunned by memory ( 268439 > 221256 ). You now have two options:

  • Create a temporary swap file . It comes down to:

     su - root fallocate -l 1G tmpswap mkswap tmpswap swapon tmpswap 

    I would choose this path as a quick solution, not to mention the fact that you really need a little shift with a small amount of memory.

    Read the article if you want this change to be permanent, it contains some valuable tips regarding permissions and fstab.

  • Try simplifying the code so that cc1 does not need so much memory. I don’t know how to do it.

+7
source

All Articles