List<Picture> pictures = Picture.findAll(); //Around 2GB of data (uses JPA/play framework)
for (Picture picture : pictures) {
byte[] b = picture.image.data; //Image raw data is stored in a different table than Picture table
System.out.println(picture.file_name + " " + b.length);
}
上記のコードjava.lang.OutOfMemoryError
は、DB内のファイル参照ではなくデータベースに画像が保存されているため、実行時にを引き起こします。
とにかく、オブジェクトの処理が終了したら、メモリを「フラッシュ」できますか?私は試しましたpicture.em().flush()
が、Iterator.remove(), System.gc()
どれもうまくいきませんでした。助けてください。