El 01/03/15 a les 22:34, fredvs ha escrit: > Ooops, in previous mail you should read (sorry)=> > >>> there are dire warnings that TThread.Create() shouldn't be overridden. >>> Should this be in the documentation if it's a significant issue? > >> It's the first time I hear it, I've been doing it forever, just like in >> the example in the same wiki page. > > Hum... same for me here... ;-( > > Do you think it could explain memory leak that i cannot solve even using > this ? => > > constructor TMyThread.Create(CreateSuspended: boolean; > const StackSize: SizeUInt); > begin > inherited Create(CreateSuspended, StackSize); > FreeOnTerminate := TRUE ; => (changed) this not working ? > ... > end;
I think it could create a memory leak if the thread terminates before the assignment of FreeOnTerminate. Unlikely (so I'd look somewhere else) but possible, so reverse the sequence, i.e. FreeOnTerminate:=True; inherited Create or create the thread suspended then start it as the last instruction in the constructor. Oh, and be careful if in the section you marked as "..." you do something that the thread needs: it is possible that the thread runs *before* the "..." section. Again, create the thread last or create it suspended and start it at the end of the creator. Bye -- Luca _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal