I would like to know if there is a way by which we can understand if an apex class is never called in recent times. In my org, the apex character limit has touched over 77%. I am sure that there are a lot of classes which are old and obsolete. How can I identify them? Is there a tool for that?

  • 2
    I took the liberty of changing your title to more accurately reflect the question you're asking. The character limit in your org is a motivation for asking the question, but it's not what your question is really asking about.
    – Derek F
    Aug 20, 2019 at 13:10

2 Answers 2


If you can wait a few months till WINTER 20, you can use MetadataComponentDependencyQueries.

This will tell you where your APEX class is used, if it's just in test-class then it should be safe to delete along with the test class.

Another option till then will be to try deleting them in the sandbox, it will give you why it cant be deleted due to dependency, check if the dependency is just test class, then delete both main and test class.

  • This will only tell about the dependencies. I believe the question is about the last time the apex class was executed in context of either vf page/lightning component etc. Aug 20, 2019 at 13:37
  • The question was not clear when it was asked.@salesforce-sas Aug 20, 2019 at 13:39
  • 1
    Anyways, thanks for the link! +1 Aug 20, 2019 at 13:40

If I understand your question correctly you want to know if the code in a certain class has been run recently. As far as I know there is no standard way to do that. You could try to collect and analyze the apex logs over some time. To find the code that is run you can look for lines with 'CODE_UNIT_STARTED'.

You could probably automate the log collection with sfdx force:apex:log:list and sfdx force:apex:log:get but you will have to enable logging for a number of users to get a complete view and with that amount of code you will probably hit the org limits pretty fast.

Not the answer you're looking for? Browse other questions tagged .