We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

The requested operation cannot be performed on a file with a user-mapped section open

The issue: Document.Save method randomly throws exception.

The app processes multiple PDFs simultaneously. The issue happens with random files. The issue cannot be reproduced at will with the same file. The same file may produce the issue 1-2 times out of 30.

Unfortunately, I cannot provide a code snippet to reproduce the issue the app has a lot of logic and I was unable to identify what lines of code may cause the issue.

System.IO.IOException: The requested operation cannot be performed on a file with a user-mapped section open.

at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)     
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)   
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)  
at System.IO.FileStream..ctor(String path, FileMode mode)    
at Aspose.Pdf.Document.#=zmCBp3wj3d_ct(String #=zkfhq0KfKswXu)     
at Aspose.Pdf.Document.Save(String outputFileName)    
...
  • Any ideas?
  • Does Aspose.PDF use memory-mapped files? Does it release all resources?

For internal reference: MDP-14453

Thanks.

@licenses

Aspose.PDF is a multithread safe API as long as one file is being accessed by one thread at a time. Also, Document.Save() method acts like Dispose() method i.e. it deallocate all the resources being used by the particular document being processed by the thread.

It is hard to determine the cause of error that you are facing. You can check in the code snippet and routine of your logic if there is a possibility for a file being accessed by two process simultaneously. You can also try to create a simple console application and try to replicate the issue with minimal code snippet and share that application with us so that we can further investigate and address the issue accordingly.

There was one more question.

Does Aspose.PDF use memory-mapped files?

@licenses

We will shortly get back to you on it.

@licenses

Not for now, although we are considering this in future to increase performance.

Hi.

Created a test project to replicate the issue.

The test project is a console app. Originally, the app contained code that changes PDFs. But after some testing, I was able to replicate the issue without this code. At the moment, the app simply opens a pdf file and then saves it back.

AsposePdfIssues.zip (286.8 KB)

A sample PDF file is included in the project.

To start the app run the following command:

.\AsposePdfIssues.exe --pdf all_metadata.pdf --iterations 10001 --threads 8

I was able to replicate the issue using the test project on the following environments:

  1. Env A
    • Winver.exe: MS Hyper-V Server 2019, Version 1809 (OS build 17763.3532)
    • CPU: 1 socket, 2 virtual processors
    • RAM: 8 GB
  2. Env B
    • winver.exe: Windows Server 2019, Version 1809 (OS build 17763.3406)
    • CPU: 1 socket, 2 virtual processors
    • RAM: 8 GB
  3. Env C
    • winver.exe: Windows 10, Version 21H2 (OS build 19044.2130)
    • CPU: 8 cores, 16 logical processors
    • RAM: 32 GB

Notes

  • Use different machines to replicate the issue.
  • You can play with the command line parameters. It is easier to reproduce the issue if the number of threads (-t parameter) is bigger than the number of logical processors.
  • Set iteration count (-i parameter) to a big value (for example, 10000).
  • Run the app multiple times until you replicate the issue on your environment.

Thanks.

@licenses

We have logged an investigation ticket as PDFNET-52849 in our issue tracking system to further analyze this case. We will look into its details and keep you posted with the status of its resolution. Please be patient and spare us some time.

We are sorry for the inconvenience.

Hello.

Is it possible to somehow change the priority of the PDFNET-52849?

This issue is really critical - I have several angry customers that constantly report new instances of this issue.

@licenses

The issue is related to API performance and we need to test for it on different environments. The issues in free support forum are resolved on first come first serve basis unlike paid support where critical issues are reported and are resolved on priority/urgent basis. Nevertheless, your concerns have been recorded and we will consider them during investigation. We will inform you once we have some more updates about its investigation.

We apologize for your inconvenience.

1 Like

Hi.

  • Have developers started to investigate the issue? Or PDFNET-52849 is still in the TODO queue?
  • Is the root cause known by now?

Thanks.

@licenses

Regretfully, no significant progress could be made towards ticket resolution yet. Your concerns were already recorded and we will surely inform you once we have some updates about ticket resolution. Please be patient and spare us some time.

We are sorry for the inconvenience.

Hi.

Was there any progress on this issue? Any updates there?

Thanks.

@licenses

We are afraid that the ticket could not get resolved due to other issues in the queue. We will surely inform you once we have some updates about its resolution. Please spare us some time. We apologize for the inconvenience.