Aspose.PDF Data Cross-Contamination Risks

Hi, My company is using Aspose to process PDF files and we are making some optimizations to improve performance. One of these was to only instantiate Aspose objects once and re-use them. For example, instead of creating a new TiffDevice every time I make a call to convert a PDF to a TIFF, I re-use the one instance created globally. Is this safe to do? Are there any risks that information from the previous document could be kept and possibly cross-contaminate with other documents? I ask because others have seen instances of this in the past, im not sure if it was an Aspose bug or something else, but I want to confirm that it is okay to re-use aspose objects like Document, JpegDevice and TiffDevice and there is no risk of having information from one document cross to the other?
A followup question would be is it safe if parallel processing is implemented? I know Aspose is not thread safe out of the box, but if threading was managed in the calling class, would there be a risk for cross-contaminating data between documents?

@ehenry120

Along with the comments that we posted in your other thread, we have not come across any issue of cross-contamination data before. Many users are using the TiffDevice and other classes in the same way you are mentioning above and they are working fine. Furthermore, if you make sure that multithreading is managed in a way that only one document will be processed at single time, the API would produce expected results. Aspose.PDF is a multi-threaded safe API as long as one document is accessed by one thread at a time.

Thank you for confirming that.

1 Like