#349200 Document that montage without -size is memory hungry

#349200#5
Date:
2006-01-21 14:06:38 UTC
From:
To:
Note: possibly related to http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=275894.


I'm trying to make an index picture of some photos, to have it printed along
with them to have an easy overview.
66 JPEGs, totaling 140MB; most 3400x2300 pixel, some with 1.3 MPixel.

Memory usage goes through the roof.


First try was
	$ montage -label %f -background '#fff' -geometry +4+4 -resize 10% *-*.jpg index.jpg
I'd have believed 140MB * 10% * 10% ~ 1.4MB; maybe times 100 while
uncompressed in memory. Having 512MB real memory I thought that to be
an easy task.

But soon I had to kill that command; top shows
 6960 flip      18   0  988m 271m 270m D 11.0 53.9   0:17.30 montage
with all of swap and main memory used.


Next I tried to convert the picture to a smaller size; thinking that it
would then be ok.
	$ convert -geometry 100x100 '*-*.jpg'
But that ate all memory, too.


Only way was to do something along
	$ for a in *-*.jpg ; do convert $a -geometry 100x100 _$a; done
	$ montage -label %f -background '#fff' -geometry +4+4 _* index.jpg
That worked.


BTW, is there a way to tell imagemagick to respect the rotation tag, and
possible sort the images by rotation? So that I get a row of portrait images,
below a row with fewer landscape images, and so on - to fully utilize the
given space?

Thank you.


Regards,

Phil

#349200#10
Date:
2008-03-19 02:32:59 UTC
From:
To:
Hi Philipp!

With a new version of ImageMagick available on Debian (version
7:6.3.7.9.dfsg1-2, available on testing and unstable), do you still
see the the memory usage problem that you reported on
http://bugs.debian.org/349200, please?

Thank you!

Best regards,
Nelson

#349200#15
Date:
2008-03-19 18:57:05 UTC
From:
To:
Hello Nelson!
Yes. It still happens.

dpkg-query says:
  ii  imagemagick       7:6.3.7.9.dfsg1-2    image manipulation programs

188MB in 85 JPEGs:
  $ montage -label %f -background '#fff' -geometry +4+4 -resize 10% *-*.jpg index.jpg

gives
  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
  698 flip      20   0  713m 490m 488m D 10.0 52.0   0:07.06 montage

Then I killed it.

Can I help you in some other way?


Regards,

Phil

#349200#22
Date:
2008-03-21 02:16:38 UTC
From:
To:
Hi Philipp!

Hum... right.
I think that one bug that I reported (http://bugs.debian.org/389604)
is also related with it. I can see a big memory usage with display
too.

I have forwarded it to
http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=10885
Lets see what upstream authors think about it.

Thank you very much for your attention!

Best regards,
Nelson

#349200#27
Date:
2008-03-21 02:47:06 UTC
From:
To:
Hi again!
What they said is:

======
Add this to your command line to trade off memory usage for I/O usage:
-limit memory 16mb -limit map 32mb. Another option is to build the
8-bit version of ImageMagick (add --with-quantum-depth=8 to the
configure command line). The 8-bit version uses 100% less memory than
the default 16-bit version.
======

I can see 5 times improvement in memory usage about bug 389604, by
using "-limit memory 16mb -limit map 32mb".

Could you try to use it and see if you get a satisfactory result, please?

Thank you!

Best regards,
Nelson

#349200#32
Date:
2008-03-21 14:53:27 UTC
From:
To:
  $ montage -limit memory 16mb -limit map 32mb -label %f -background '#fff' -geometry +4+4 -resize 10% *-*.jpg index.jpg
  montage: invalid argument for option `16mb': -limit.

In the documentation
http://www.imagemagick.org/script/command-line-options.php#limit
I see a reference to the "-list" option - but that doesn't work, too:

  $ montage -list resource
  montage: unrecognized option `-list'.
  $ montage -list list
  montage: unrecognized option `-list'.


Any help?

#349200#37
Date:
2008-03-21 15:27:35 UTC
From:
To:
Never mind; with a bit of experimenting I got it:

$ montage -limit memory 16000000 -limit map 160000000 -label %f -background '#fff' -geometry +4+4 -resize 10% '*_*.jpg' index.jpg
...
montage: unable to extend cache `20080216_150344.jpg': No space left on device.
montage: unable to extend cache `20080217_015805.jpg': No space left on device.
montage: unable to extend cache `20080217_015859.jpg': No space left on device.

top said
 8247 flip      20   0  203m 156m 152m D 17.3 16.6   0:04.74 montage

So the 160M are taken ... but I don't get it to work.

#349200#42
Date:
2008-12-21 20:56:11 UTC
From:
To:
Package: imagemagick
Version: 7:6.3.7.9.dfsg1-2.1+lenny1
Tags: unreproducible

According to upstream you are out of temp space.

Also tags to unreproducible, because I can not reproduce on my laptop.

I think we could close this bug report if you agree.


Regards

#349200#47
Date:
2008-12-22 10:52:26 UTC
From:
To:
I don't think so ...

With 54 .jpgs in a directory, with (all together) 161MB disk usage, and
3M main memory/24G free disk space it still won't work with current:
	ii  imagemagick                          7:6.3.7.9.dfsg1-3

	11514 flip      20   0 2795m 1.6g 1.6g R 23.0 60.2   0:27.94 montage
Then I killed it, because the whole machine became unresponsive.
That's a pity ... I just run this command:

	montage -label %f -background '#fff' -geometry +4+4 -resize 10% *_*.jpg index.jpg
Well, it still doesn't work for me.

#349200#52
Date:
2008-12-22 12:45:47 UTC
From:
To:
Ok will try your command surelly this week. Could you try before I
will test some simple step?

Could you try please to set MAGICK_TMPDIR to disk directory (for
instance ~/tmp) ? Maybe imagemagick use  shm filesystem (some admin
set tmp dir
to shm). Could you check that you have not enable quota (a lot of tool
return disk full instead of overquota).

Thank you for your report,

Bastien

#349200#57
Date:
2008-12-22 12:52:19 UTC
From:
To:
Doesn't help:
	15886 flip      20   0 2308m 2.1g 2.1g R  6.8 79.9   0:22.04 montage


But thank you for your answer!


Regards,

Phil

#349200#62
Date:
2008-12-22 13:06:46 UTC
From:
To:
Hi!

Can you run it with strace (and send us the output or put it online), please?

Thank you!

Best regards,
Nelson

#349200#67
Date:
2008-12-22 14:25:45 UTC
From:
To:
Here you are, hope that helps ... I killed it when it got to 2GB memory usage,
and removed all read() calls after the first in each block.

It just seems to allocate memory for all pictures ...


Regards,

Phil

#349200#72
Date:
2009-01-11 18:37:53 UTC
From:
To:
Upstream asks to try this command:
      montage -limit memory 0 -limit map 0 -label %f -background '#fff' -geometry +4+4 -resize 10% '*_*.jpg' index.jpg

Could you give a try?

Regards

#349200#77
Date:
2009-01-13 17:30:09 UTC
From:
To:
Hello Bastien!
That gives me this:

montage: unable to extend cache `20080906_161736.jpg': No space left on device.
montage: unable to extend cache `20080906_161740.jpg': No space left on device.
montage: unable to extend cache `20080907_101831.jpg': No space left on device.
montage: unable to extend cache `20080913_132543.jpg': No space left on device.
montage: unable to extend cache `20080920_143251.jpg': No space left on device.
...
montage: unable to extend cache `20080904_144311.jpg': No space left on device.
montage: Memory allocation failed `20080904_144311.jpg'.
montage: unable to extend cache `20080904_144319.jpg': No space left on device.
montage: Memory allocation failed `20080904_144319.jpg'.
montage: unable to extend cache `20080906_151317.jpg': No space left on device.
montage: Memory allocation failed `20080906_151317.jpg'.
montage: unable to extend cache `20080906_161723.jpg': No space left on device.
montage: Memory allocation failed `20080906_161723.jpg'.
montage: unable to extend cache `index.jpg': No space left on device.


$ free
             total       used       free     shared    buffers     cached
Mem:       2771872    1360320    1411552          0      15448     373612
-/+ buffers/cache:     971260    1800612
Swap:      3678876      14792    3664084
$ LANG=C df -k .
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/md0              73299008  47880996  21694556  69% /


Thank you.


Regards,

Phil

#349200#82
Date:
2009-01-13 17:32:48 UTC
From:
To:
I forgot to mention that it behaves much better; maximum memory usage is
~60MB:

$ top -b | grep montage
10937 flip      20   0 58408 2916 2080 R 31.9  0.1   0:00.96 montage
10937 flip      20   0 58580 3096 2136 D 41.9  0.1   0:02.22 montage
10937 flip      20   0 58780 3300 2192 R 39.1  0.1   0:03.40 montage
10937 flip      20   0 58960 3496 2232 R 41.2  0.1   0:04.64 montage
10937 flip      20   0 59164 3672 2288 R 45.2  0.1   0:06.00 montage
10937 flip      20   0 59364 3884 2336 R 43.2  0.1   0:07.30 montage
10937 flip      20   0 59656 4208 2404 R 42.6  0.2   0:08.58 montage
10937 flip      20   0 59964 4496 2444 R 45.2  0.2   0:09.94 montage
10937 flip      20   0 60268 4776 2500 R 44.5  0.2   0:11.28 montage
10937 flip      20   0 60436 5040 2556 R 44.5  0.2   0:12.62 montage


Sadly it doesn't work ;-(


Regards,

Phil

#349200#87
Date:
2009-01-13 18:51:13 UTC
From:
To:

Could you please do a before montage

MAGICK_TMPDIR=.;  montage -limit memory 0 -limit map 0 -label %f
-background '#fff'
 -geometry +4+4 -resize 10% '*_*.jpg' index.jpg

and monitor disk space during the command run ?

Could we BTW continue this dicussion directly upstream ? They are no
value to continu here, because it is an upstream problem.
and I do only copy and paste of your answer.

please write on:
http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=10885

Thank you

#349200#92
Date:
2009-01-13 19:38:46 UTC
From:
To:
Ok; thank you.

Do you monitor this thread for some solution, if there is any?


Regards,

Phil

#349200#97
Date:
2009-01-13 19:49:34 UTC
From:
To:
Yes I have subsribed to the thread :)

bastien

#349200#102
Date:
2009-01-15 18:20:54 UTC
From:
To:
retitle 349200 Document that montage without -size is memory hungry
severity 349200 wishlist
thanks

This command work:
      montage -label %f -background '#fff' -size 128x128 -geometry 128x128+4+4 '*_*.jpg' index.jpg

According to upstream:

Regards

Bastien