Tell me more ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm getting a "diff: memory exhausted" error when trying to diff two 27 GB files that are largely similar on a linux box with CentOS 5 and 4 GBs of RAM.

This is a known problem, it seems: http://zotline.com/shownote.zot/NoteNum/4375.html

I would expect there to be an alternative for such an essential utility, but I can't find one. I imagine the solution would have to use temporary files rather than memory to store the information it needs.

I tried to use rdiff and xdelta, but they are better for showing the changes between two files, like a patch, and are not that useful for inspecting the differences between two files.

Tried VBinDiff, but it is a visual tool which is better for comparing binary files. I need something that can pipe the differences to STDOUT like regular diff.

There are a lot of other utilities such as vimdiff that only work with smaller files.

I've also read about Solaris bdiff but I could not find a port to linux.

Any ideas besides splitting the file into smaller pieces? I have 40 of these files so trying to avoid the work of breaking them up.

Thanks

share|improve this question
what version of xdelta did you try? xdelta3 or xdelta1? – nmuntz Aug 10 '10 at 16:17
It was version 1.1.4. Does xdelta3 provide different functionality? I just checked the online doc and it still seems to be about providing "deltas". – Tom B Aug 11 '10 at 15:35

2 Answers

I found this link

diff -H might help, or you can try installing the textproc/2bsd-diff port which apparently doesn't try to load the files into RAM, so it can work on large files more easily.

I'm not sure if you tried those two options or if they might work for you. Good luck.

share|improve this answer

If the files are identical (same length) except for a few byte values, you can use a script like following (w is the number of bytes per line to hexdump, adjust to your display width):

w=12;
while read -ru7 x && read -ru8 y;
do
  [ ".$x" = ".$y" ] || echo "$x | $y";
done 7< <(od -vw$w -tx1z FILE1) 8< <(od -vw$w -tx1z FILE2) > DIFF-FILE1-FILE2 &

less DIFF-FILE1-FILE2

It's not very fast, but does the job.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.