How to get a number of instantiated objects/exceptions

The code I'm researching loosely follows this flow:

  1. My first callback
  2. Black box
  3. My second callback

I can modify 1 and 3 no problem but modifying 2 is difficult.

However I think that step 2 has some optimization problems, namely:

  • instantiates lots of objects
  • throws/catches lots of exceptions (not logged)

Is there a way to count these two metrics?


use Do $System.OBJ.ShowObjects() to list your refernced objects.

The output goes to $IO or eventually a TmpCharStream.
The start of the last line is your count of orefs .

That's orefs currently in memory.

I need the number of instantiations, preferably by class.

Objects are created and destroyed on a second stage.

It is not directly what you look for but GlobalReferences are to some extent proportional by some factor to instantiations.
especially if you deduct GlobalReads.
##CLASS(%SYS.ProcessQuery) could be a source for those figures

if you compare it to "normal" code it could be an indicator.