Re: Unpack 7z archive fails due to out of memory problem

Discussion of bugs and problems found in Altap Salamander. In your reports, please be as descriptive as possible, and report one incident per report. Do not post crash reports here, send us the generated bug report by email instead, please.
User avatar
mdruiter
Posts: 262
Joined: 22 Feb 2006, 15:33
Location: Amsterdam, The Netherlands
Contact:

Re: Unpack 7z archive fails due to out of memory problem

Post by mdruiter »

With some (old and new) 7z archives, Unpack archive does not seem to work.
I just press Alt+F6 on it and Enter, and I get:
---------------------------
Altap Salamander 2.53 beta 2
---------------------------
Insufficient memory to allocate 1231194888 bytes. Try to release some memory (e.g. close some running application) and click Retry. If it does not help, you can click Ignore to pass memory allocation error to this application or click Abort to terminate this application.
---------------------------
Abort Retry Ignore
---------------------------

That's not what I expected. :/
Copying files from the archive does work normally.

An example 7z is attached.
Attachments
1.7z
(470 Bytes) Downloaded 410 times
User avatar
zarevak
Plugin Developer
Plugin Developer
Posts: 789
Joined: 04 Feb 2006, 16:49
Location: Prague, Czech Republic

Re: Unpack 7z archive fails

Post by zarevak »

I've reported problems with memory management in 7zip plugin about a year ago in this Czech thread: 7-Zip komprese - málo paměti (fragmentace, /3GB) (althought it was about compression)

7Zip plugin is based on 7Zip application, which doesn't have problems allocating large blocks of memory. Salamander on the other side has memory space fragmented because of all the different libraries loaded into it and cannot find continuous free block of 1GB size.
Sadly the memory allocation routines are deep in the 7zip codebase and would be very hard to rewrite to allocate the required memory in smaller chunks.

But I may be wrong and your archive may be just corrupted :oops:
Slanec
Posts: 66
Joined: 17 Nov 2009, 19:00

Re: Unpack 7z archive fails

Post by Slanec »

...but then
Copying files from the archive does work normally.
wouldn't be true. I can't really see a difference between unpacking and copying files out of an archive.
User avatar
Ether
Posts: 1471
Joined: 10 May 2007, 16:08
Location: Czech Republic
Contact:

Re: Unpack 7z archive fails

Post by Ether »

Unfortunately, it's not caused by corrupted archives. I, too, have encountered a 7-zip archive created by AS that required circa half a gigabyte of memory to unpack (luckily, I was able to free this ridiculous amount of memory and unpack the archive). I can send it by email if required.

On the other hand, I cannot reproduce the problem with mdruiter's attached archive. The files extract just fine using both Alt+F9 on archive and F5 from archive, without any memory hogging or swapping (using simple Task Manager and disk activity observation).
Ελληνικά rulez.
User avatar
zarevak
Plugin Developer
Plugin Developer
Posts: 789
Joined: 04 Feb 2006, 16:49
Location: Prague, Czech Republic

Re: Unpack 7z archive fails

Post by zarevak »

Just to clarify the memory allocation which is done in two steps:
1) reservation - regular 32-bit program can reserve about 2GB of memory without any actual memory being used or backed up by the page file....
2) commiting - this step makes the memory actualy usable

The reservation system is useful in cases when programmers need to use continuous memory blocks, but don't have the need to use them completely.
- program can reserve 1GB block and then can use basic pointer arithmetics and memory indexing... only the parts which are actualy used can commited
-- array item number 1000 is on memory address:
arrayPtr + 1000 * sizeof(arrayItem)
- easy ;)
- drawback is the reserved block needs to have free continuous address space - if the memory is too fragmented, there may not be enough space to reserve the block (1GB is very large piece in 4GB address space) - the problem almost doesn't exist in 64-bit world, because the address space is huge and 1GB is very small part...

If the program would only reserve and commit smaller blocks, it would need to have much more complicated pointer arithmetics and would require some table of all allocated blocks...
-- array item number 1000 is on memory address:
blocksPtr[1000 / items_in_block] + (1000 % items_in_block) * sizeof(arrayItem)
- much harder and slower :(

More information about memory allocation can be found in Mark Russinovich's blog post: Pushing the Limits of Windows: Virtual Memory

I don't know the internals of 7-zip code, but I wanted to point out, that program can fail to allocate 1GB of memory even when it will actually use only 1MB of this memory...
Jan Patera
Plugin Developer
Plugin Developer
Posts: 707
Joined: 08 Dec 2005, 14:33
Location: Prague, Czech Republic
Contact:

Re: Unpack 7z archive fails

Post by Jan Patera »

Slanec wrote:...but then
Copying files from the archive does work normally.
wouldn't be true. I can't really see a difference between unpacking and copying files out of an archive.
There can be diference if the archive is not solid and mdruiter is copying out of it only some files.
Jan Patera
Plugin Developer
Plugin Developer
Posts: 707
Joined: 08 Dec 2005, 14:33
Location: Prague, Czech Republic
Contact:

Re: Unpack 7z archive fails

Post by Jan Patera »

mdruiter wrote:With some (old and new) 7z archives, Unpack archive does not seem to work.
> Insufficient memory to allocate 1231194888 bytes.
Yes, this can happen on PPMD-compressed files with very high dictionary and word sizes. See Zarevak's notes & thread.
However, the largest block needed to extract your particular file 1.7z is just 1MB, it only uses LZMA and only with small dictionary size (see the detailed view). Are you sure it is the right example?
User avatar
mdruiter
Posts: 262
Joined: 22 Feb 2006, 15:33
Location: Amsterdam, The Netherlands
Contact:

Re: Unpack 7z archive fails

Post by mdruiter »

I still have the problem on this (solid) archive.
Copying all (two) files works just fine.

Wait, once I restarted Salamander, Unpack worked again. So apparently it depends on (memory?) state... :-(
I'm using Windows Vista x64, by the way.

How can I debug this problem further, if I encounter it again?
Last edited by mdruiter on 02 Jun 2010, 12:42, edited 1 time in total.
Jan Rysavy
ALTAP Staff
ALTAP Staff
Posts: 5231
Joined: 08 Dec 2005, 06:34
Location: Novy Bor, Czech Republic
Contact:

Re: Unpack 7z archive fails

Post by Jan Rysavy »

We know about this problem, it looks there isn't "easy" solution for now.
The x64 version of Altap Salamander will solve it.

Starting a new instance of Salamander, where plugins are not loaded (default state of most AS plugins) could help you now.
User avatar
mdruiter
Posts: 262
Joined: 22 Feb 2006, 15:33
Location: Amsterdam, The Netherlands
Contact:

Re: Unpack 7z archive fails

Post by mdruiter »

We know about this problem, it looks there isn't "easy" solution for now.
Jan, do you understand why it asks for so much memory for so small a file?
Jan Patera
Plugin Developer
Plugin Developer
Posts: 707
Joined: 08 Dec 2005, 14:33
Location: Prague, Czech Republic
Contact:

Re: Unpack 7z archive fails

Post by Jan Patera »

mdruiter wrote:
We know about this problem, it looks there isn't "easy" solution for now.
Jan, do you understand why it asks for so much memory for so small a file?
No. As I said, the largest block the 7zip plugin and dll try to allocate is 1 MB. Have you tried older versions?
User avatar
mdruiter
Posts: 262
Joined: 22 Feb 2006, 15:33
Location: Amsterdam, The Netherlands
Contact:

Re: Unpack 7z archive fails

Post by mdruiter »

I meant to ask Jan Rysavy. :-)
Jan Rysavy
ALTAP Staff
ALTAP Staff
Posts: 5231
Joined: 08 Dec 2005, 06:34
Location: Novy Bor, Czech Republic
Contact:

Re: Unpack 7z archive fails

Post by Jan Rysavy »

I have no idea, Jan Patera knows all about 7-Zip plugin, he did all patches and maintenance for several years.
User avatar
mdruiter
Posts: 262
Joined: 22 Feb 2006, 15:33
Location: Amsterdam, The Netherlands
Contact:

Re: Unpack 7z archive fails

Post by mdruiter »

I'm confused. :?
From Jan Rysavy I understand, that the source of the problem is known. And that it's related to x64, which sounds sensible. At least I run Vista x64 too.
But then again, why does the plugin ask for the enormous amount of memory? How could that be related to Windows-bitness? :?:

As I'm not as convinced as you might be that the problem is understood, I'ld like to know whether I could help to debug it any further, if it occurs again...
Jan Rysavy
ALTAP Staff
ALTAP Staff
Posts: 5231
Joined: 08 Dec 2005, 06:34
Location: Novy Bor, Czech Republic
Contact:

Re: Unpack 7z archive fails

Post by Jan Rysavy »

I looks like my mistake, I'm sorry. Please ignore my post about known problem.
Post Reply