Compare by Contents says files are different when equal

English support forum

Moderators: Hacker, petermad, Stefan2, white

User avatar
Hacker
Moderator
Moderator
Posts: 13142
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Compare by Contents says files are different when equal

Post by *Hacker »

Hi,
Yesterday I was comparing two AVI's, about 350 MB each. The compare tool stopped with the message that there is not enough memory (ok, we know about this problem), saying the files were DIFFERENT.

However, upon creating MD5sums of said files, they were equal.
How come?

TIA
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
ado
Senior Member
Senior Member
Posts: 445
Joined: 2003-02-18, 13:22 UTC
Location: Slovakia, Pezinok

Post by *ado »

hi,
I am sure this is question to Christan, but I believe there is simple possible explanation. "No enough memory" is pretty bad exceptional state from programmer's point of view very hard to handle. This is possible explanation:
You are reading both files let's say by 10k and then comparing. With last 15k of memory you read 10k from the first file, read from the second file fails on out of memory. You are getting error message and since for program one file is 10k longer (file pointer is pointing to different places of files), obviously they are different :-)
As I wrote ...one possible explanation, I am pretty sure Christian will give you different one

ado
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50806
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

TC does the following:
1. It reads the two files in blocks of 32k or so, compares the blocks, reads the next two blocks etc. until both files are compared.
2. If the files are identical, TC shows a message that the files are the same, and doesn't load the visual compare tool
3. If the files are different, it maps them into memory and shows them. If they cannot be mapped into memory, the error will be shown that the files are different and there isn't enough memory.

So what does it mean in your case? Either the files are really different, or there was some kind of read error or RAM error during the initial comparison...
Author of Total Commander
https://www.ghisler.com
User avatar
Hacker
Moderator
Moderator
Posts: 13142
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

OK, if I happen to come across the same behavior again, I might resurrect this thread.
Thanks.

Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
Hacker
Moderator
Moderator
Posts: 13142
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

[mod]Moved to the English forum.

Hacker (Moderator)[/mod]
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
Hacker
Moderator
Moderator
Posts: 13142
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

Similar situation today, however, the files were indeed different, so my gripe is about something else.

Why does TC say there is not enough memory, when comparing two files?
- the files are both 367,032,320 bytes large
- I have 2,2 GB of free memory
- TC's memory usage (Private bytes) never goes above 30 MB
- the comparison stops at 6% saying there is not enough memory.

Why?

TIA
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
Hacker
Moderator
Moderator
Posts: 13142
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

Hm, now it works fine. Perhaps something else is relevant except the amount of free memory?

Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50806
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Yes, the problem is memory fragmentation. TC requests the memory in one block, and if many small blocks have been requested across the memory, there will not be enough free memory in one block for the file. This isn't about real physical memory, but about the virtual address space. TC just maps the entire file into memory, which makes the comparison function much simpler and faster. For technical details, see CreateFileMapping and MapViewOfFile:
http://msdn2.microsoft.com/en-us/library/aa366761(VS.85).aspx

It may help to close and restart just Total Commander. If not, you will need to restart Windows.
Author of Total Commander
https://www.ghisler.com
User avatar
Hacker
Moderator
Moderator
Posts: 13142
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

Aha! I see. Thank you.

Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
d
Member
Member
Posts: 157
Joined: 2007-02-05, 14:54 UTC

Post by *d »

2ghisler:
cannot you fix it so that it will not say that they are different?
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50806
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Well, TC first compares the two files via ReadFile loop, which doesn't need much memory. It shows "files identical" if they are the same. If not, then it tries to open them in the compare tool. If this fails too, it says that they are different (which they are because they were really compared).
Author of Total Commander
https://www.ghisler.com
d
Member
Member
Posts: 157
Joined: 2007-02-05, 14:54 UTC

Post by *d »

(i'm sorry/pardon/excuse me/i apologise (and one more word it seems to me (i remember a little) i have seen in this forum)). (i do not know yet which is better to use.) i had an file on cd which was written with error message and size of a file in it was correct, and i tried to compare it. and then had seen this topic and wrote here thinking that in my case also tc could not compare though it simple that it is not so.. now i have tried to create checksum and have found out that that file is unreadable.
RickyGold
Junior Member
Junior Member
Posts: 18
Joined: 2008-09-23, 13:51 UTC

Post by *RickyGold »

Hello everybody.
Today I've got a "not enough memory" message from TC while performing a "compare by content" operation on a couple of 750MB files. I find this a bit strange because I used to do this many times in the past without any problem (my PC has 2GB RAM).
I tried also restarting TC, and then restarting Windows, but no effect.
After reading this thread, I also looked around for a way to defragment memory, but I found out that the only way to obtain this is by specific applications/utilities, while I don't like to foddle around and install programs only for this task.

Note that just before that, I made 2 upgrades to my PC: first I installed WinXP SP3, then upgraded from my old 6.54 version of TC to the latest 7.04.
Could my problem be related to this ?
Do you have any suggestion ?
Thanks.



Edited 30min later:
Well, I found my way to carry out the compare using the command "FC /B" in a CMD prompt (quite fast as well) - obviously not easy to map differences, since they are listed vertically and only in the form "address - byte". Lookin forward for a more user-friendly way in TC, though :)
User avatar
Aezay
Senior Member
Senior Member
Posts: 269
Joined: 2003-02-12, 07:27 UTC
Location: Denmark
Contact:

Post by *Aezay »

Why not just load the files dynamically as you scroll like the Lister already does?
Of all the planets I've been to, this one is my favorite.
User avatar
ado
Senior Member
Senior Member
Posts: 445
Joined: 2003-02-18, 13:22 UTC
Location: Slovakia, Pezinok

Post by *ado »

read Ghisler's response from "Thu 17.Apr.2008 10:29". It does, but once he tries to open it in compare tools situation is different. That tool is looking back and forth trying to find the same parts. But...actually in this case we are talking about a binary files. You are right for binary comparison that tool can possibly work as the Lister does.
On another hand - do you think it would be worth to implement it when TC now supports external compare tool?

ado
Post Reply