Hi Enrico,
Enrico Maria Giordano wrote:We need to clear understand if and where the problem is.
IMHO the "where" is clear: buffering in a string built of small pieces in a intense computing program could lead in reallocation problems due to Harbour's memory management lack of garbage collection. It is a known problem. Please check xHarbour's online documentation about aSizeAlloc() and aLenAlloc(), that addresses the same problem with arrays growing with aAdds.
The "if" is up to the programmer: known the conditions under a program is running ( like Tim's xml generation or, in my case, a text file ) a programmer should consider if the problem's known conditions are met, and in that case which solution should be taken: unbuffered write to disk, insert in the program's code some forced calls to Harbour's GC with unpredictable results, or an smart buffer to moderate the IO.
I've solved the problems, and so Tim and James did, so it doesn't look like 'premature optimization', better call it 'reengineering'
I see immediate uses of this solution for me: logging to files, html/xml generation, etc. In case of logging, the problem is not the memory one but the high I/O, so buffering seems to apply.