forked from wolfSSL/wolfssl
Merge pull request #798 from toddouska/trackmem
add deallocs to memory tracker
This commit is contained in:
@ -64,6 +64,7 @@
|
|||||||
|
|
||||||
typedef struct memoryStats {
|
typedef struct memoryStats {
|
||||||
size_t totalAllocs; /* number of allocations */
|
size_t totalAllocs; /* number of allocations */
|
||||||
|
size_t totalDeallocs; /* number of deallocations */
|
||||||
size_t totalBytes; /* total number of bytes allocated */
|
size_t totalBytes; /* total number of bytes allocated */
|
||||||
size_t peakBytes; /* concurrent max bytes */
|
size_t peakBytes; /* concurrent max bytes */
|
||||||
size_t currentBytes; /* total current bytes in use */
|
size_t currentBytes; /* total current bytes in use */
|
||||||
@ -149,6 +150,7 @@
|
|||||||
|
|
||||||
#ifdef DO_MEM_STATS
|
#ifdef DO_MEM_STATS
|
||||||
ourMemStats.currentBytes -= mt->u.hint.thisSize;
|
ourMemStats.currentBytes -= mt->u.hint.thisSize;
|
||||||
|
ourMemStats.totalDeallocs++;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WOLFSSL_DEBUG_MEMORY
|
#ifdef WOLFSSL_DEBUG_MEMORY
|
||||||
@ -204,6 +206,7 @@
|
|||||||
|
|
||||||
#ifdef DO_MEM_STATS
|
#ifdef DO_MEM_STATS
|
||||||
ourMemStats.totalAllocs = 0;
|
ourMemStats.totalAllocs = 0;
|
||||||
|
ourMemStats.totalDeallocs = 0;
|
||||||
ourMemStats.totalBytes = 0;
|
ourMemStats.totalBytes = 0;
|
||||||
ourMemStats.peakBytes = 0;
|
ourMemStats.peakBytes = 0;
|
||||||
ourMemStats.currentBytes = 0;
|
ourMemStats.currentBytes = 0;
|
||||||
@ -217,6 +220,8 @@
|
|||||||
#ifdef DO_MEM_STATS
|
#ifdef DO_MEM_STATS
|
||||||
printf("total Allocs = %9lu\n",
|
printf("total Allocs = %9lu\n",
|
||||||
(unsigned long)ourMemStats.totalAllocs);
|
(unsigned long)ourMemStats.totalAllocs);
|
||||||
|
printf("total Deallocs = %9lu\n",
|
||||||
|
(unsigned long)ourMemStats.totalDeallocs);
|
||||||
printf("total Bytes = %9lu\n",
|
printf("total Bytes = %9lu\n",
|
||||||
(unsigned long)ourMemStats.totalBytes);
|
(unsigned long)ourMemStats.totalBytes);
|
||||||
printf("peak Bytes = %9lu\n",
|
printf("peak Bytes = %9lu\n",
|
||||||
|
Reference in New Issue
Block a user