!7 cmodule TestAutoSegmenter > DynSingleFunctionWithPrintLog { long maxMBs = 256; // save dat memory transient long dataSize; transient new L images; srecord TestImage(BufferedImage image, Rect boardLocation) {} bool spaceToSpare() { ret toMB(dataSize) < maxMBs; } void doIt { LPair in = asLinkedList(agiBlue_chess_trainingImagesWithBoardLocations()); while (nempty(in)) { if (!spaceToSpare()) break with print("Out of space (" + toM(dataSize) + " MB used), skipping " + nImages(in)); S name, Rect location = unpair popFirst(in); pcall { BufferedImage img = loadImage2(parseImageSnippetURL(agiBlue_lookupInSlice(agiBlue_chessBoardRecognitionTrainingImagesSliceID(), name, "input image"))); images.add(new TestImage(img, location)); dataSize += bufferedImageDataSize(img); print("Have " + nImages(images) + ", data size: " + toM(dataSize) + " MB"); } } print("Loading done"); } }