Skip to main content
Participating Frequently
March 4, 2025
Answered

Out of memory exception when calling addAnnotations

  • March 4, 2025
  • 2 replies
  • 1248 views

Hi all. I work on an application that applies annotations to PDF documents.

 

After loading the PDF viewer we call the annotation manager API's addAnnotations method. The promise eventually errors out with the following error (see image below) "Error: std::bad_alloc,std::bad_alloc", and we can see that some of the annotations have not been added.

 

Some important context is that we are attempted to add up to 500 different annotations to a given PDF. From my (admittedly basic) tests, the limit appears to be around 120 annotations before the error happens.

 

I have attached an image of the browser's console. This is in Google Chrome.

 

 

Is there a known maximum number of annotations that is supported? I did not see a number mentioned in the docs. 

 

I tried chaining the addAnnotation promises in batches of 100 at a time, but the error still occured.

 

Very interested to hear if anyone has also had this same issue, or if any Adobe devs would like to take a look that would be excellent and greatly appreciated.

 

Thanks for reading.

Correct answer Joel Geraci

Hi Joel, I had been thinking along a similar line, however from reading the docs I didn't see an event regarding a page change. Could you point me in the direction?

 

In our application the user can either interact with a non-adobe component, and this can navigate to a page using the `gotoLocation` method on the viewer API. But obviously they can also interact with the Adobe client itself, which we don't have any awareness of currently.


You'd listen for the CURRENT_ACTIVE_PAGE event.

2 replies

Joel Geraci
Community Expert
Community Expert
March 6, 2025

Try adding them in batches of 10.

Participating Frequently
March 6, 2025
quote

Try adding them in batches of 10.


By @Joel Geraci

 

Hi Joel, thanks for your reply. Batches of 10 unfortunately ends up in the same result. I've attached my console log, after each promise resolved I printed the batch index. I also tried batches of 5, and despite getting a little further this time, still ends up failing.

 

 

Participating Frequently
March 6, 2025

Further to add, even running one at a time I am unable to get even to 200 annotations added. Strangely batches of 5 seems to get the furthest at around ~200 annotations.

Participating Frequently
March 6, 2025

I wanted to also attach a copy of the adobe log message that was being sent in the network event:

 

[
 {
   "level":"error",
   "message":"Reached maximum number of initial events",
   "sessionId":"ba2ede6a-5049-4d09-b823-7a61c1b9fd77",
   "viewSDKAppVersion":"3.27.1_3.2.10-ea8924cb",
   "tenantId":"--private--",
   "callingApp":"dc-view-sdk",
   "externalUserId":"--private--",
   "clientId":"--private",
   "client_timestamp":"2025-03-06T14:13:53.240Z",
   "context":"Analytics"
 }
]