I was trying to combine 10 pdfs. The total pages are around 100,000 pages.

I am using

pdftk 1.pdf ... 10.pdf output total.pdf

the total size of pdf will be around 300+mb.

I get the following error

Too many heap sections: Increase MAXHINCR or MAX_HEAP_SECTS

How can i increase MAXHINCR or MAX_HEAP_SECTS

  • 1
    What use is a TEN MILLION page pdf? Try adding them 1 at a time.
    – waltinator
    Aug 22, 2020 at 12:59
  • Sorry its 100,000 pages. So you mean I should try to club two at a time and keep apending one more pdf
    – Santhosh
    Aug 22, 2020 at 14:18
  • "club"? What does "club" mean?
    – waltinator
    Aug 22, 2020 at 15:09

1 Answer 1


The values in the error message are set at compile time, so they're useful only if you're building from source.

I suggest you add the .pdf files one at a time.

Something like

for i in $(seq 1 10); do
   if [[ $i -eq 1 ]] ; then
        cp $i.pdf a.tmp.pdf
        pdftk a.tmp.pdf $i.pdf output b.tmp.pdf
        mv b.tmp.pdf a.tmp.pdf
mv a.tmp.pdf total.pdf

Warning I have not tried this.

  • 1
    I will check this
    – Santhosh
    Aug 22, 2020 at 15:50
  • I am using now stapler it does not give any error
    – Santhosh
    Aug 23, 2020 at 6:57
  • this is slower and could not try till end
    – Santhosh
    Aug 23, 2020 at 13:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .