Free Support Forum - aspose.com

Server CPU 100% after a Concatenate

Hi,


We are currently investigating a problem that sometimes cause our CPU to go at 100% usage.

The method that seems to have a problem is Concatenate from the PdfFileEditor class.

Here’s the code calling the metohd :

public byte[] ConcatenerPdfs(ICollection<byte[]> pdfs)
{
MemoryStream[] streams = new MemoryStream[pdfs.Count];
int i = 0;
foreach (byte[] pdf in pdfs)
{
MemoryStream rapportStream = new MemoryStream(pdf);
streams[i] = rapportStream;
i++;
}

using (MemoryStream outputStream = new MemoryStream())
{
PdfFileEditor pdfEditor = new PdfFileEditor();
lock (_lock)
{
pdfEditor.Concatenate(streams, outputStream);
}

return outputStream.ToArray();
}
}

Here’s 3 stack traces of the problem :

mscorlib.dll!System.Collections.Hashtable.this[object].get(object key) + 0x7b bytes
Aspose.Pdf.dll!„..() + 0x90 bytes
Aspose.Pdf.dll!...() + 0x236 bytes
Aspose.Pdf.dll!€.‚.() + 0x164 bytes
Aspose.Pdf.dll!...() + 0x4e0 bytes
Aspose.Pdf.dll!€.‚.() + 0x164 bytes
Aspose.Pdf.dll!..() + 0x119 bytes
Aspose.Pdf.dll!„..() + 0x198 bytes
Aspose.Pdf.dll!...() + 0x236 bytes
Aspose.Pdf.dll!€.‚.() + 0x164 bytes
Aspose.Pdf.dll!...() + 0x335 bytes
Aspose.Pdf.dll!€.‚.() + 0x164 bytes
Aspose.Pdf.dll!...() + 0x4e0 bytes
Aspose.Pdf.dll!€.‚.() + 0x164 bytes
Aspose.Pdf.dll!..() + 0x119 bytes
Aspose.Pdf.dll!„..() + 0x198 bytes
Aspose.Pdf.dll!.e..() + 0x608 bytes
Aspose.Pdf.dll!€.‚.() + 0x164 bytes
Aspose.Pdf.dll!€..() + 0x46e bytes
Aspose.Pdf.dll!.e.() + 0x74 bytes
Aspose.Pdf.dll!..() + 0x86 bytes
Aspose.Pdf.dll!..() + 0x60 bytes
Aspose.Pdf.dll!..() + 0xe5 bytes
Aspose.Pdf.dll!..() + 0x310 bytes
Aspose.Pdf.dll!..() + 0xe5 bytes
Aspose.Pdf.dll!..() + 0x197 bytes
Aspose.Pdf.dll!..() + 0x60 bytes
Aspose.Pdf.dll!..() + 0xe5 bytes
Aspose.Pdf.dll!..() + 0x197 bytes
Aspose.Pdf.dll!..() + 0x60 bytes
Aspose.Pdf.dll!..() + 0x69 bytes
Aspose.Pdf.dll!..() + 0x2b7 bytes
Aspose.Pdf.dll!..() + 0xe5 bytes
Aspose.Pdf.dll!..() + 0x197 bytes
Aspose.Pdf.dll!..() + 0x60 bytes
Aspose.Pdf.dll!Aspose.Pdf.Facades.PdfFileEditor.() + 0x4be bytes
Aspose.Pdf.dll!Aspose.Pdf.Facades.PdfFileEditor.Concatenate(System.IO.Stream[] inputStream = {System.IO.MemoryStream[5]}, System.IO.Stream outputStream = {System.IO.MemoryStream}) + 0x8a bytes

mscorlib.dll!System.IO.BinaryReader.Read(byte[] buffer, int index, int count) + 0x55 bytes
Aspose.Pdf.dll!€..() + 0x39 bytes
Aspose.Pdf.dll!„..() + 0x42 bytes
Aspose.Pdf.dll!...() + 0x236 bytes
Aspose.Pdf.dll!€.‚.() + 0x164 bytes
Aspose.Pdf.dll!...() + 0x4e0 bytes
Aspose.Pdf.dll!€.‚.() + 0x164 bytes
Aspose.Pdf.dll!..() + 0x119 bytes
Aspose.Pdf.dll!„..() + 0x198 bytes
Aspose.Pdf.dll!...() + 0x236 bytes
Aspose.Pdf.dll!€.‚.() + 0x164 bytes
Aspose.Pdf.dll!...() + 0x335 bytes
Aspose.Pdf.dll!€.‚.() + 0x164 bytes
Aspose.Pdf.dll!...() + 0x4e0 bytes
Aspose.Pdf.dll!€.‚.() + 0x164 bytes
Aspose.Pdf.dll!..() + 0x119 bytes
Aspose.Pdf.dll!„..() + 0x198 bytes
Aspose.Pdf.dll!.e..() + 0x608 bytes
Aspose.Pdf.dll!€.‚.() + 0x164 bytes
Aspose.Pdf.dll!€..() + 0x46e bytes
Aspose.Pdf.dll!.e.() + 0x74 bytes
Aspose.Pdf.dll!..() + 0x86 bytes
Aspose.Pdf.dll!..() + 0x60 bytes
Aspose.Pdf.dll!..() + 0xe5 bytes
Aspose.Pdf.dll!..() + 0x310 bytes
Aspose.Pdf.dll!..() + 0xe5 bytes
Aspose.Pdf.dll!..() + 0x197 bytes
Aspose.Pdf.dll!..() + 0x60 bytes
Aspose.Pdf.dll!..() + 0xe5 bytes
Aspose.Pdf.dll!..() + 0x197 bytes
Aspose.Pdf.dll!..() + 0x60 bytes
Aspose.Pdf.dll!..() + 0x69 bytes
Aspose.Pdf.dll!..() + 0x2b7 bytes
Aspose.Pdf.dll!..() + 0xe5 bytes
Aspose.Pdf.dll!..() + 0x197 bytes
Aspose.Pdf.dll!..() + 0x60 bytes
Aspose.Pdf.dll!Aspose.Pdf.Facades.PdfFileEditor.() + 0x4be bytes
Aspose.Pdf.dll!Aspose.Pdf.Facades.PdfFileEditor.Concatenate(System.IO.Stream[] inputStream = {System.IO.MemoryStream[5]}, System.IO.Stream outputStream = {System.IO.MemoryStream}) + 0x8a bytes

clr.dll!GcInfoDecoder::EnumerateLiveSlots() + 0x623 bytes
[Managed to Native Transition]
Aspose.Pdf.dll!€..() + 0x1e bytes
Aspose.Pdf.dll!„..() + 0x42 bytes
Aspose.Pdf.dll!...() + 0x236 bytes
Aspose.Pdf.dll!€.‚.() + 0x164 bytes
Aspose.Pdf.dll!...() + 0x4e0 bytes
Aspose.Pdf.dll!€.‚.() + 0x164 bytes
Aspose.Pdf.dll!..() + 0x119 bytes
Aspose.Pdf.dll!„..() + 0x198 bytes
Aspose.Pdf.dll!...() + 0x236 bytes
Aspose.Pdf.dll!€.‚.() + 0x164 bytes
Aspose.Pdf.dll!...() + 0x335 bytes
Aspose.Pdf.dll!€.‚.() + 0x164 bytes
Aspose.Pdf.dll!...() + 0x4e0 bytes
Aspose.Pdf.dll!€.‚.() + 0x164 bytes
Aspose.Pdf.dll!..() + 0x119 bytes
Aspose.Pdf.dll!„..() + 0x198 bytes
Aspose.Pdf.dll!.e..() + 0x608 bytes
Aspose.Pdf.dll!€.‚.() + 0x164 bytes
Aspose.Pdf.dll!€..() + 0x46e bytes
Aspose.Pdf.dll!.e.() + 0x74 bytes
Aspose.Pdf.dll!..() + 0x86 bytes
Aspose.Pdf.dll!..() + 0x60 bytes
Aspose.Pdf.dll!..() + 0xe5 bytes
Aspose.Pdf.dll!..() + 0x310 bytes
Aspose.Pdf.dll!..() + 0xe5 bytes
Aspose.Pdf.dll!..() + 0x197 bytes
Aspose.Pdf.dll!..() + 0x60 bytes
Aspose.Pdf.dll!..() + 0xe5 bytes
Aspose.Pdf.dll!..() + 0x197 bytes
Aspose.Pdf.dll!..() + 0x60 bytes
Aspose.Pdf.dll!..() + 0x69 bytes
Aspose.Pdf.dll!..() + 0x2b7 bytes
Aspose.Pdf.dll!..() + 0xe5 bytes
Aspose.Pdf.dll!..() + 0x197 bytes
Aspose.Pdf.dll!..() + 0x60 bytes
Aspose.Pdf.dll!Aspose.Pdf.Facades.PdfFileEditor.() + 0x4be bytes
Aspose.Pdf.dll!Aspose.Pdf.Facades.PdfFileEditor.Concatenate(System.IO.Stream[] inputStream = {System.IO.MemoryStream[5]}, System.IO.Stream outputStream = {System.IO.MemoryStream}) + 0x8a bytes

We are using Aspose.NET 6.4 and it is not possible for us to upgrade to the newest version at the moment.

Thanks for helping me.
Guillaume

Hi Guillaume,

Sorry for the inconvenience faced. I’m afraid Aspose.Pdf has no restriction on number/size of Pdf document generation. Memory consumption or CPU usage depends upon the contents and size of the resultant files along with your system resources. Please increase your system memory according to your need, hopefully CPU usage issue would be resolved.


Moreover, over the time we had made many fixes/enhancement in API. We would suggest you to test the scenario with latest Aspose.Pdf API as it includes all the fixes/enhancement made till date.

Please feel free to contact us for any further assistance.


Best Regards,