delphi - How to finalise a threadvar string to prevent a leak? -


This is not a big leak, but I think it would be nice to clean, but I've found that my Delphi XE Code is because it is defined as a threader, as it should be, but when the thread is finished, then it is not clearly writing such a variable.

Is there a way to manually clear the string when thread is threaded? Do I assign empty string to it, or set it to zero or something?

Assign spaces to do this string, set it to zero or final form Call on () They are all equivalent and they will assign the collection to remove their memory leak.


In response to Marco's comment, it is clear:

Dynamic variables that are generally compiled (long strings, wide strings, dynamic arrays, variants and Interfaces) can be declared with the threader, but the compiler does not automatically freeze pile-allocated memory created by each thread of execution. If you use these data types in thread variables, then it is your responsibility to remove your memory from within the thread, before the thread ends: For example:

  Threader S: Ensystring; S: = 'ABCDEFGHIKLMNOPQRTUVX'; ... S: =; The memory used by //s               ;   

It is easy to see that thread local variables are not automatically handled:

  Programs LeakMe; {$ APPTYPE console} threader: string; Starting ReportMemory Lexon Shutdown: = True; S: = 'Leak me'; End.    

Comments