And the report works ok, but… In another report with more records (almost 3000) did not work. I don’t know if it’s advisable to keep increasing the parameters.
You need to try to figure out where all of the memory is being used. Are you loading lots of Active Record models at the same time? If so, you could load in batches of, say, 100 at a time, then unset and load the next batch.
If the PDF generator is eating all of the memory, there may not be much you can do other than raise the memory limit or find alternative PDF generation software.
Did you determine whether you’re hitting the memory or execution time limit?