How do I measure heap usage in a NET+OS application?

Problem: 

    You have developed a NET+OS application and are concerned about the amount of RAM (heap) consumed by the application, either as a whole or at different stages of the application's life. How do you measure this? This knowledgebase article answers this question.

Analysis: 
    NET+OS ships with an API entitled NABspGetHeapSnapshot. NABspGetHeapSnapshot is described in the API reference guide at System Software Services->Miscellaneous Data Types and Macros->Functions->NABspGetHeapSnapshot. NABspGetHeapSnapshot expects a pointer
to an NABspMallocStats structure. It is expected that the application allocatesmemory for this pointer and frees the pointer when done. StructureNABspMallocStats is also described in the API reference guide at System Software Services->Miscellaneous Data Types and Macros->Types->NABspMallocStats. NABspMallocStats is made up of a number of integer fields that are filled in by NABspGetHeapSnapshot. Please see the description in the API reference guide for more details on the API and the fields in the structure.

Conclusion:
    Use API NABspGetHeapSnapshot for measuring heap usage within a NET+OS application.   

Note: NABspGetHeapSnapshot was first added to NET+OS V7.4 and is not 
available in NET+OS versions older than NET+OS V7.4.

Last updated: Oct 21, 2024

Recently Viewed

No recently viewed articles

Did you find this article helpful?