Free Support Forum - aspose.com

JpegDevice Process has become slow in an single application

I am using the library to convert pdf pages to jpg images using the JpgDevice class and its Process method into a memory stream.


e.g.
jpegDevice.Process(page, ms)

In a production application this method is taking 5-6 seconds for each page this is called for.

So the first thing I did was to create a test project (attached to this post) to try and reproduce this on my system, the same system running running the mentioned production code where the slowness exists. This test project does not reproduce the issue even though I am doing my best to mimic the environment. Same object setup and using the same pdf document.

Does anyone have any idea why I would see difference in speed, and how this could be resolved?

Hi Claire,


Thanks for contacting support.

I have tested the scenario using the latest release of Aspose.Pdf for .NET 9.6.0 and as per my observations, the PDF to Image conversion is completed in 2.7 Seconds in Visual Studio 2010 application with target platform 4.0 running over Windows 7 (x64). I have used the same code snippet which you have shared in earlier post. Can you please try using the latest release and in case the problem still persists, please share some details regarding your working environment. We are sorry for this inconvenience.

Aspose creating JpgDevice object duration: 113ms)
Aspose processing JpgDevice duration: 692ms)
Converting memory stream to image string duration: 0ms)
Aspose creating JpgDevice object duration: 0ms)
Aspose processing JpgDevice duration: 64ms)
Converting memory stream to image string duration: 0ms)
Aspose creating JpgDevice object duration: 0ms)
Aspose processing JpgDevice duration: 57ms)
Converting memory stream to image string duration: 0ms)
Aspose creating JpgDevice object duration: 0ms)
Aspose processing JpgDevice duration: 57ms)
Converting memory stream to image string duration: 0ms)
Aspose creating JpgDevice object duration: 0ms)
Aspose processing JpgDevice duration: 58ms)
Converting memory stream to image string duration: 0ms)
Aspose creating JpgDevice object duration: 0ms)
Aspose processing JpgDevice duration: 61ms)
Converting memory stream to image string duration: 0ms)
Aspose creating JpgDevice object duration: 0ms)
Aspose processing JpgDevice duration: 56ms)
Converting memory stream to image string duration: 0ms)
Aspose creating JpgDevice object duration: 0ms)
Aspose processing JpgDevice duration: 65ms)
Converting memory stream to image string duration: 0ms)
Aspose creating JpgDevice object duration: 0ms)
Aspose processing JpgDevice duration: 58ms)
Converting memory stream to image string duration: 0ms)
Aspose creating JpgDevice object duration: 0ms)
Aspose processing JpgDevice duration: 59ms)
Converting memory stream to image string duration: 0ms)
Aspose creating JpgDevice object duration: 0ms)
Aspose processing JpgDevice duration: 59ms)
Converting memory stream to image string duration: 0ms)
Aspose creating JpgDevice object duration: 0ms)
Aspose processing JpgDevice duration: 56ms)
Converting memory stream to image string duration: 1ms)
Aspose creating JpgDevice object duration: 1ms)
Aspose processing JpgDevice duration: 57ms)
Converting memory stream to image string duration: 0ms)
Aspose creating JpgDevice object duration: 0ms)
Aspose processing JpgDevice duration: 58ms)
Converting memory stream to image string duration: 0ms)
Aspose creating JpgDevice object duration: 0ms)
Aspose processing JpgDevice duration: 61ms)
Converting memory stream to image string duration: 0ms)
Aspose creating JpgDevice object duration: 0ms)
Aspose processing JpgDevice duration: 58ms)
Converting memory stream to image string duration: 0ms)
Aspose creating JpgDevice object duration: 0ms)
Aspose processing JpgDevice duration: 55ms)
Converting memory stream to image string duration: 0ms)
Aspose creating JpgDevice object duration: 0ms)
Aspose processing JpgDevice duration: 65ms)
Converting memory stream to image string duration: 0ms)
Aspose creating JpgDevice object duration: 0ms)
Aspose processing JpgDevice duration: 60ms)
Converting memory stream to image string duration: 0ms)
Aspose creating JpgDevice object duration: 0ms)
Aspose processing JpgDevice duration: 59ms)
Converting memory stream to image string duration: 0ms)
Aspose creating JpgDevice object duration: 0ms)
Aspose processing JpgDevice duration: 59ms)
Converting memory stream to image string duration: 0ms)
Aspose creating JpgDevice object duration: 0ms)
Aspose processing JpgDevice duration: 55ms)
Converting memory stream to image string duration: 0ms)
Aspose creating JpgDevice object duration: 0ms)
Aspose processing JpgDevice duration: 59ms)
Converting memory stream to image string duration: 0ms)
Aspose creating JpgDevice object duration: 0ms)
Aspose processing JpgDevice duration: 59ms)
Converting memory stream to image string duration: 0ms)
Aspose creating JpgDevice object duration: 0ms)
Aspose processing JpgDevice duration: 59ms)
Converting memory stream to image string duration: 0ms)
Aspose creating JpgDevice object duration: 0ms)
Aspose processing JpgDevice duration: 58ms)
Converting memory stream to image string duration: 0ms)
Aspose creating JpgDevice object duration: 0ms)
Aspose processing JpgDevice duration: 55ms)
Converting memory stream to image string duration: 0ms)
Aspose creating JpgDevice object duration: 0ms)
Aspose processing JpgDevice duration: 62ms)
Converting memory stream to image string duration: 0ms)
Aspose creating JpgDevice object duration: 0ms)
Aspose processing JpgDevice duration: 59ms)
Converting memory stream to image string duration: 0ms)
Aspose creating JpgDevice object duration: 0ms)
Aspose processing JpgDevice duration: 60ms)
Converting memory stream to image string duration: 0ms)
Aspose creating JpgDevice object duration: 0ms)
Aspose processing JpgDevice duration: 55ms)
Converting memory stream to image string duration: 0ms)
Aspose creating JpgDevice object duration: 0ms)
Aspose processing JpgDevice duration: 61ms)
Converting memory stream to image string duration: 0ms)
Aspose creating JpgDevice object duration: 0ms)
Aspose processing JpgDevice duration: 57ms)
Converting memory stream to image string duration: 0ms)
Aspose creating JpgDevice object duration: 0ms)
Aspose processing JpgDevice duration: 59ms)
Converting memory stream to image string duration: 0ms)

Thanks for the response.


I did download and update the aspose library with no change in behavior.

The demo project works fine as expected, then in the production codebase it is very slow. I am timing the function the same way in the production code, so it seems something is affecting the Aspose library’s ability to perform. Do you know what might do this?

Hi Claire,


Can you please share some details regarding production environment i.e. Operating System, .NET Framework version etc.

I was referring to production code not the environment. I am running the test AND production code on my personal dev server. My system is running Windows Server 2012, on a Intel i7-2600 with 16GB RAM.


Both test and production code is running in .NET 4.5.

The production code is running in a ASP.NET application, so IIS is managing the application.

This is not occurring on all systems, it seems that it may be tied to a recent Acrobat X update; however, this could be a coincidence.

Hi Claire,


Thanks for sharing the details.

Aspose.Pdf is not dependent upon Adobe Acrobat or Adobe Reader and during my testing with code snippet shared earlier, I did not manage to reproduce the issue. Can you please share some sample application so that we can try replicating the issue at our end. We are sorry for this inconvenience.

Thanks Nayyer.


This is my problem exactly. I can’t reproduce the issue in a test project. It only occurs in our production codebase, which would be nearly impossible to share with you and configure.

The production codebase is a webapp running within IIS. I will create a new test app and see if it is IIS that is causing the issue.

Thanks.

Hi Claire,


Thanks for your comprehension.

We will be waiting for the resource project from your side so that we can further investigate the problem in our environment.

Hi,


I have just the same issue.

A dotNet website on a windows server 2012 production server converts a page from a PDF to a JPEG in 30s.

On a similar test server, the same file/page takes 1.7~2.5 seconds.

I have isolated the time consuming call:
jpegDevice.Process(page, imageStream);

Maybe it could help to solve this issue if you tell us which resources are allocated by this function that can block. Also it seems that it is CPU intensive. Is it waiting for some resource?

Thanks,
Paulo Fernandes

Hi Paulo,


Thanks for sharing your findings. We will look into it and share our findings with you soon.

Best Regards,

pf71:
I have just the same issue.

A dotNet website on a windows server 2012 production server converts a page from a PDF to a JPEG in 30s.

On a similar test server, the same file/page takes 1.7~2.5 seconds.

I have isolated the time consuming call:
jpegDevice.Process(page, imageStream);

Maybe it could help to solve this issue if you tell us which resources are allocated by this function that can block. Also it seems that it is CPU intensive. Is it waiting for some resource?
Hi Paulo,

Thanks for using our API’s.

The JpegDevice.Process(…) is an actual method for PDF to JPEG conversion and the time taken by API depends upon the structure and complexity of input PDF file. However as per your description, the conversion time is larger on ASP.NET Website as compared to console application. Therefore, in order for us in figure out the reasons behind this issue, please share some sample project, along with resource files, so that we can test the conversion in our environment. We are sorry for this inconvenience.