We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
always runs out of memory, bad code? (Read 1658 times)
always runs out of memory, bad code?
Mar 18th, 2008, 12:55am
 
Hi everyone. I've been working toward a video installation. Currently I'm stumped over an error that happens every time it runs [eventually].

you can run this but you need the blob detection library and you need your own .mov .

Right now i can't get you the exact error message, but i will update this post with it tomorrow. Basically though, there's some sort of memory problem i believe. I've read through numerous documentation throughout this site. I'm still not clear though - hence i'm asking here.

Thanks for your time, really. I'm going to update with error details tomorrow. Note that, the bigger video files/resolutions cause failure sooner than smaller counter-parts.
JMMK



// ==================================================
// import/declare
// ==================================================
import processing.video.*;
import blobDetection.*;

BlobDetection theBlobDetection;
Capture       cam;
Movie         myMovie;
PImage        img;
boolean       newFrame       = false;
int           oldBlobNumber  = 99;                   // the number of
blobs on the last scan, before current scan
int           elapsedTime    = 0;                    // time since
calendar was flipped
float         myMovieSpeed   = 1;                    // playback
speed, 1 is normal
float         pointer        = 0;                    // Where the
tracking is aimed at, 0 if aimed at nowhere
// ==================================================
// setup()
// ==================================================
void setup(){

size(640, 360);
cam = new Capture(this,  640, 360, "IIDC FireWire Video",15); // Capture

//video
frameRate(15);
myMovie = new Movie(this, "1upLow.mov");
myMovie.speed(myMovieSpeed);
myMovie.loop();

// BlobDetection
img = new PImage(80,60);                           // img which will
be sent to detection (a smaller copy of the cam frame);
theBlobDetection = new BlobDetection(img.width, img.height);
theBlobDetection.setPosDiscrimination(true);
theBlobDetection.setThreshold(0.2f);               // will detect
bright areas whose luminosity > 0.2f;
}
// ==================================================
// captureEvent()
// ==================================================
void captureEvent(Capture cam){
cam.read();
newFrame = true;
}
// ==================================================
// draw()
// ==================================================
void draw(){
//video playback
myMovie.read();
image(myMovie, 0, 0,width,height);

//blobs
if(newFrame){
  newFrame=false;
  //image(cam,0,0,width,height);                   // uncomment this
line to see what the camera sees
  img.copy(cam, 0, 0, cam.width, cam.height,
  0, 0, img.width, img.height);
  theBlobDetection.computeBlobs(img.pixels);
  drawBlobs();
}

//tracking
if(elapsedTime>60 && theBlobDetection.getBlobNb() < 20 &&
theBlobDetection.getBlobNb() != oldBlobNumber){
  oldBlobNumber = theBlobDetection.getBlobNb();    // we're about to
make a new scan so move the current blob to the last blob slot
  elapsedTime   = 0;                               // we're about to
make a new scan so reset the elapsed time

  switch(theBlobDetection.getBlobNb()){
  case 6:                                          // case # where
number is the number of blobs you want to track
    myMovieSpeed = 8;                              // speed of playback
    myMovie.speed(myMovieSpeed);
    pointer = 5;                                   // frame target
of this blob case
    break;
  case 3:
    myMovieSpeed = 8;
    myMovie.speed(myMovieSpeed);
    pointer = 50;
    break;
  case 12:
    myMovieSpeed = 8;
    myMovie.speed(myMovieSpeed);
    pointer = 30;
    break;
  default:                                         // if none of the
cases are found, then it's a bad blob entry we don't want it
    break;
  }
}
if(pointer > myMovie.time()-2 && pointer < myMovie.time()+2){ //
once the tracking target is found, this if statement will return the
video to normal speed
  myMovieSpeed = 1;
  myMovie.speed(myMovieSpeed);
  pointer      = 0;
}
myMovie.speed(myMovieSpeed);
elapsedTime++;
println("Blob#: "+theBlobDetection.getBlobNb() + " || oldBlob#:
"+oldBlobNumber + " || elapsedTime: "+elapsedTime +" |||||
pointerVtime " + pointer + "/" + myMovie.time());
//theBlobDetection.getBlobNb() is the number of blobs, this is for
degbugging
}
// ==================================================
// drawBlobsAndEdges()
// ==================================================
void drawBlobs(){                                    // this is the
code that magically detects blobs
noFill();
Blob b;
for (int n=0 ; n<theBlobDetection.getBlobNb() ; n++){
  b=theBlobDetection.getBlob(n);
  if(b!=null){
      strokeWeight(1);stroke(255,0,0);             // the visual
appearance of the blobs
      rect(b.xMin*width,b.yMin*height,b.w*width,b.h*height);
  }
}
}
Re: always runs out of memory, bad code?
Reply #1 - Mar 19th, 2008, 5:12pm
 
here is the error message:


java(277,0x8c0a00) malloc: *** mmap(size=1216512) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** error for object 0xffc4b000: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** mmap(size=1216512) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** error for object 0xffc4b000: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** mmap(size=1216512) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** error for object 0xffc4b000: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** mmap(size=1216512) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** error for object 0xffc4b000: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** mmap(size=1216512) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** error for object 0xffc4b000: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Re: always runs out of memory, bad code?
Reply #2 - Mar 19th, 2008, 5:13pm
 
continued:

(error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** error for object 0xffd29000: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** mmap(size=1216512) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** error for object 0xffd29000: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** mmap(size=1216512) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** error for object 0xffd29000: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** mmap(size=1216512) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** error for object 0xffd29000: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** mmap(size=1216512) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** error for object 0xffd29000: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** mmap(size=1216512) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** error for object 0xffd29000: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** mmap(size=1216512) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** error for object 0xffd29000: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** mmap(size=1216512) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** error for object 0xffd29000: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** mmap(size=1216512) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** error for object 0xffd29000: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** mmap(size=1216512) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** error for object 0xffd29000: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug

Blob#: 12 || oldBlob#: 12 || elapsedTime: 318 ||||| pointerVtime 30.0/771.0833

java(277,0x8c0a00) malloc: *** mmap(size=630784) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
java(277,0x8e0200) malloc: *** mmap(size=921600) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** mmap(size=630784) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** mmap(size=630784) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** mmap(size=630784) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** mmap(size=630784) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** mmap(size=630784) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** mmap(size=630784) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug


Exception in thread "
java(277,0x8c0a00) malloc: *** mmap(size=630784) failed (error code=12)
Re: always runs out of memory, bad code?
Reply #3 - Mar 19th, 2008, 5:13pm
 
continued....

*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** error for object 0xffd29000: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** mmap(size=1216512) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** error for object 0xffd29000: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** mmap(size=1216512) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** error for object 0xffd29000: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** mmap(size=1216512) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** error for object 0xffd29000: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** mmap(size=1216512) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** error for object 0xffd29000: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** mmap(size=1216512) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** error for object 0xffd29000: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** mmap(size=1216512) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** error for object 0xffd29000: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** mmap(size=1216512) failed
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** mmap(size=630784) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** mmap(size=630784) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug

Thread-3" java.lang.OutOfMemoryError: requested 921600 bytes for jint in /SourceCache/HotSpot15/HotSpot15-119/src/share/vm/prims/jni.cpp. Out of swap space?


Blob#: 12 || oldBlob#: 12 || elapsedTime: 317 ||||| pointerVtime 30.0/770.08

java(277,0x8c0a00) malloc: *** mmap(size=1216512) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** error for object 0xffd29000: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
java(277,0x8c0a00) malloc: *** mmap(size=1216512) failed (error code=12)
Re: always runs out of memory, bad code?
Reply #4 - Mar 19th, 2008, 5:48pm
 
This is an error i got after adjusting the code slightly


java(420,0x8eb800) malloc: *** mmap(size=921600) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug


Exception in thread "Thread-3" java.lang.OutOfMemoryError: requested 921600 bytes for jint in /SourceCache/HotSpot15/HotSpot15-119/src/share/vm/prims/jni.cpp. Out of swap space?
Page Index Toggle Pages: 1