Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2013-07

[ISSUE] FCL-Web: TUploadedFile causing memory leak?

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Van Canneyt
to silvioprog
silvioprog wrote

There are several things VERY wrong with your test program. First:

    VFile.Read(VBuf, VBufLen); // reading only the first 1024 bytes ...
  Overrides the VBUf address.
  It must be
    VFile.Read(VBuf[0], VBufLen); // reading only the first 1024 bytes ...
  Secondly,
    VFile.Free; // free stream allowing to delete uploaded file, but, it causes
  Frees the stream, but does not set the Stream property of TUploadedFile to nil.
  When TUploadedFile is freed, it frees again the memory stream, causing an access violation.
  I do not understand how your program could ever function.
  I got access violations all over the place trying to run it.
  Anyway, after fixing the 2 above issues it ran smootly.
  Now, I suspect that the DeleteTempUploadedFiles does not work because Windows has the files locked when you attempt to delete them, so I changed TUploadedFile.DeleteTempUploadedFile
  so it first frees the stream if there is one.
  (cannot test that under Linux, where the demo runs fine)

Michael.

Reply by email

silvioprog
to Michael Van Canneyt

2013/7/15 Michael Van Canneyt

Show quoted text 37 lines
On Sun, 14 Jul 2013, silvioprog wrote: > Hello, > Please see: > > http://bugs.freepascal.org/**view.php?id=24746<http://bugs.freepascal.org/view.php?id=24746> > There are several things VERY wrong with your test program. First: VFile.Read(VBuf, VBufLen); // reading only the first 1024 bytes ... Overrides the VBUf address. It must be VFile.Read(VBuf[0], VBufLen); // reading only the first 1024 bytes ... Secondly, VFile.Free; // free stream allowing to delete uploaded file, but, it causes Frees the stream, but does not set the Stream property of TUploadedFile to nil. When TUploadedFile is freed, it frees again the memory stream, causing an access violation. I do not understand how your program could ever function. I got access violations all over the place trying to run it. Anyway, after fixing the 2 above issues it ran smootly. Now, I suspect that the DeleteTempUploadedFiles does not work because Windows has the files locked when you attempt to delete them, so I changed TUploadedFile.**DeleteTempUploadedFile so it first frees the stream if there is one. (cannot test that under Linux, where the demo runs fine) Michael.

Yes! :)

I'll test it and reply via mantis. Wait me please ...

Silvio Clécio My public projects - github.com/silvioprog

Reply by email