Memory leak of entries
Closed this issue · 9 comments
As far as I see, when deleting files/directories the entries to them still exist in the directory (they will be reused if new file will be created in same directory, but not for files content/other directory).
It is not a lot of memory per entry, but if we are talking about multiple such entries it became issue.
Hi @smithBraun , Thank you for the feedback. We will address this issues. For now a work around could be implemented from Application code. for eg The directory (ABC) in where multiple files and sub directories are deleted, should be renamed (DEF). A new directory with original name (ABC) should be created and all the files in directory DEF should be renamed to ABC\file_name
Reference code:
/* Main directory create */
status += fx_directory_create(&ram_disk, "A");
/* Create sub directories */
for (i = 0; i < 100; i++)
{
sprintf(file_name, "A\\%04d.TXT", i);
status += fx_file_create(&ram_disk, file_name);
}
/* Delete Multiple directories */
for (i = 0; i < 99; i++)
{
sprintf(file_name, "A\\%04d.TXT", i);
status += fx_file_delete(&ram_disk, file_name);
}
/* At this point Directory "A" has one file but entries for deleted files still exist
No rename the directory to "B" */
status += fx_directory_rename(&ram_disk, "A", "B");
/* Create new directory with name "A" */
status += fx_directory_create(&ram_disk, "A");
/* Rename file files present in B to A\file_name so that they get moved to new directory A */
status += fx_file_rename(&ram_disk, "B\\0099.TXT", "A\\0099.TXT");
/* Now delete directory B which will free the memory used by deleted file entries */
status += fx_directory_delete(&ram_disk, "B");
Thanks for taking a look on it @bhnaphade
Unfortunately your workaround requires lot of operations and I think it will fail if I will try to do it after I am out of memory.
Do you have any time estimation for fixing it?
Hi @bhnaphade,
Thanks for having a look into the issue. Could you please provide estimation when fix for this issue will be available ? any chance to expedite the process ?
/Tzvika
We are investigating the issue. I've created an internal tracking work item - we'll try to have a fix as soon as possible.
Hi @bhnaphade
Any update on this issue ?
Hi,
Can you kindly please let us know what is the status of this issue ?
Hi @bhnaphade
Can you please let me know if there is any update on this issue or when can we expect a fix for it ?
We have verified out implementation against the specification and Windows itself, so we do not believe a change is warranted at this time. If the sub-directory is completely empty, we recommend deleting the sub-directory and then creating it again. This will result with one cluster allocated for the new instance of the sub-directory. The other cluster(s) will have been freed by the sub-directory delete.