EnumerateFiles causes memory fragmentation
Brought to you by:
tpsfadmin
EnumerateFiles causes memory fragmentation that can result in consumption of all memory and program failure. While attempting to completely traverse a drive's directory structure, this procedure will fail as it attempts to add a filename to the Tstrings that holds found file names. The error message implies that the blame lies with the Tstrings running out of memory but the problems lies, more correctly, with the heavy memory fragmentation from the recursive traverse of the drive using FindFirst(), FindNext() and their FindClose(). Is there an alternate design for EnumerateFiles that might reduce memory fragmentation and program crashes?
A simple demonstration of EnumerateFiles failing for lack of memory