You are not logged in.
Pages: 1
Delphi 11.3, mORMot2 GitHub commit 5395 (bda0951)
1) Memory leak in function T7zWriter.AddBuffer. Must soOwned be used and not soReference.
procedure T7zWriter.AddBuffer(const ZipName: RawUtf8;
const Data: RawByteString);
begin
AddStream(TRawByteStringStream.Create(Data), soReference, // <-- soOwned
faArchive, 0, 0, ZipName, false, false);
end;
2) In function T7zWriter.AddStream should be written:
...
item.Stream := Stream;
// item.Size := Stream.Size;
if Stream <> Nil then
item.Size := Stream.Size;
3) Can an T7zWriter.AddDirectory function be added?
With best regards
Thomas
Offline
I've created 7z wrapper years ago, it supports more of 7z options (GetNumberOfFormats, GetHandlerProperty2, self extracting). To create dir in 7z you have to pass empty file name, perhaps if you expose T7zWriter.AddOrReplace it could be done.
Here's my code in case someone want's to add more functionality to this implementation:
https://www.dropbox.com/s/iszoge0frqocf … er.7z?dl=0
Last edited by igors233 (2023-05-02 02:59:56)
Offline
@thomas
Please try https://github.com/synopse/mORMot2/commit/72799230
Thanks for the report.
@igors233
Nice wrapper!
You should have published it on github as reference - it would have helped me, and may help others.
Offline
There was no leak I am afraid. The TRawByteStream was properly released.
With your soReference modification, I have an access violation now during normal process.
So I have reverted the change with
https://github.com/synopse/mORMot2/commit/cbcf0e1d
I have checked with FastMM4 in fulldebugmode that it does not show any memory leak.
Offline
There was no leak I am afraid. The TRawByteStream was properly released.
With your soReference modification, I have an access violation now during normal process.
You're right. Sorry, didn't test properly there. That works:
libWriter.AddStream(TRawByteStringStream.Create(content), soReference, faArchive, 0, 0, 'TestFolder', false, false);
A stream with no content for any combination results in an memory leak:
libWriter.AddStream(TRawByteStringStream.Create(''), soReference {soOwned}, faDirectory, 0, 0, 'TestFolder', True, False);
This error message is displayed:
An unexpected memory leak has occurred. The unexpected small block leaks are:
21 - 28 bytes: TRawByteStringStream x 1
Without content it only works properly with soOwned. That was the thread that triggered this post.
With best regards
Thomas
Offline
Offline
With Commit 5420 (e4ccc8e), it behaves as expected in my tests. Thanks a lot for that.
With best regards
Thomas
Offline
Pages: 1