Hi,
I am using Eclipse MAT APIs to analyze the heap dump file. I am calling SnapshotFactory.openSnapshot() and passing the heap dump file as an argument to this method and getting the snapshot object.
Once the snapshot object is returned I am trying to delete the heap dump file from the disk. But I am getting the below error message while deleting a file. It looks like the file is still open in SnapshotFactory.openSnapshot() method.
Error - java.nio.file.FileSystemException: <HeapDump-File-Path>: The process cannot access the file because it is being used by another process
Here is a sample code:
try {
String filePath = "HEAP_DUMP_PATH";
File hdFile = new File(filePath);
ISnapshot snapshot = SnapshotFactory.openSnapshot(hdFile,
new HashMap<String, String>(), new SysOutProgressListener());
Path path = Paths.get(filePath);
Boolean isDeleted = Files.deleteIfExists(path);
} catch(Exception e) {
e.printStackTrace();
}
[Updated on: Thu, 29 September 2022 09:27]
Report message to a moderator