I am extracting PPTX presentation to separate images.
After the extraction, Java Heap is not cleared properly and many objects are still left.
What are we missing here?
Screenshot from 2020-12-10 10-57-40.png (131.7 KB)
Dummy implementation of a logic:
public static void main(String[] args) {
String path = ""; // your path
Presentation presentation = null;
try (InputStream is = new FileInputStream(path)) {
presentation = new Presentation(is);
StreamSupport.stream(presentation.getSlides().spliterator(), false)
.map(Main::getImage)
.forEach(Main::consumer);
} catch (IOException e) {
e.printStackTrace();
} finally {
if (presentation != null) {
presentation.dispose();
}
}
}
private static void consumer(BufferedImage img) {
// initial logic
//ImageIO.write(img, IMG_EXTENSION, slideImage);
// more other logic
}
private static BufferedImage getImage(ISlide slide) {
return slide.getThumbnail(new Dimension(960, 720));
}