@petarian
Thank you for being patient.
We have investigated the ticket and would like to update you that, we use java.awt and the following method works in such way: java.awt.Font.createFont(int fontFormat, InputStream fontStream)
The temp files will be deleted by JVM with using ShutdownHook when the program exits normally.
https://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html#addShutdownHook(java.lang.Thread)
Java tracker blocks 20 the last used temp files and does not allow to delete them during process.
Java does not allow to handle this.
Also, notice please, that method: MemoryCleaner.clearAllTempFiles();
- deletes only files from temp directory that placed in the sub-folder “aspose_pdf” or have name that starts as “aspose_”.
For example the following code does not use Aspose, but blocks 20 from 40 files in temp folder. We cannot delete them even from file manager when it in the line System.out
. on debug mode. But when program is finished the temp folder will be empty.
File tmpDir = new File("C:\\MyTemp");
System.setProperty("java.io.tmpdir", "C:\\MyTemp");
for (int i = 0; i<40; i++) {
InputStream stream = null;
try {
File file =new File("C:\\Windows\\Fonts\\arial.ttf");
stream = new FileInputStream(file);
java.awt.Font font = java.awt.Font.createFont(java.awt.Font.TRUETYPE_FONT, stream);
System.out.println("Font Family: "+ font.getFamily() );
} catch (Exception e) {
e.printStackTrace();
} finally {
if (stream != null) {
try {
stream.close();
} catch (Exception e2) {
}
}
}
}
MemoryCleaner.clearAllTempFiles();
System.out.println("Num files left in the TEMP folder: " + tmpDir.listFiles().length);
We hope this will be helpful. Please feel free to contact us if you need any further assistance.