Changeset c58ead7


Ignore:
Timestamp:
Sep 11, 2023, 12:12:17 PM (8 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
73d0a84c
Parents:
5cfb8b1
Message:

add malloc_stats_clear routine to zero the heap master and all active thread heaps

Location:
libcfa/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/heap.cfa

    r5cfb8b1 rc58ead7  
    1010// Created On       : Tue Dec 19 21:58:35 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug  2 18:48:30 2023
    13 // Update Count     : 1614
     12// Last Modified On : Mon Sep 11 11:21:10 2023
     13// Update Count     : 1615
    1414//
    1515
     
    691691        return stats;
    692692} // collectStats
     693
     694static inline void clearStats() {
     695        lock( mgrLock );
     696
     697        // Zero the heap master and all active thread heaps.
     698        HeapStatisticsCtor( heapMaster.stats );
     699        for ( Heap * heap = heapMaster.heapManagersList; heap; heap = heap->nextHeapManager ) {
     700                HeapStatisticsCtor( heap->stats );
     701        } // for
     702
     703        unlock( mgrLock );
     704} // clearStats
    693705#endif // __STATISTICS__
    694706
     
    15561568
    15571569
     1570        // Zero the heap master and all active thread heaps.
     1571        void malloc_stats_clear() {
     1572                #ifdef __STATISTICS__
     1573                clearStats();
     1574                #else
     1575                #define MALLOC_STATS_MSG "malloc_stats statistics disabled.\n"
     1576                if ( write( STDERR_FILENO, MALLOC_STATS_MSG, sizeof( MALLOC_STATS_MSG ) - 1 /* size includes '\0' */ ) == -1 ) {
     1577                        abort( "**** Error **** write failed in malloc_stats" );
     1578                } // if
     1579                #endif // __STATISTICS__
     1580        } // malloc_stats_clear
     1581
     1582
    15581583        // Changes the file descriptor where malloc_stats() writes statistics.
    15591584        int malloc_stats_fd( int fd __attribute__(( unused )) ) libcfa_public {
  • libcfa/src/heap.hfa

    r5cfb8b1 rc58ead7  
    1010// Created On       : Tue May 26 11:23:55 2020
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Oct  4 19:08:55 2022
    13 // Update Count     : 23
     12// Last Modified On : Mon Sep 11 11:18:18 2023
     13// Update Count     : 24
    1414//
    1515
     
    4343        size_t malloc_mmap_start();                                                     // crossover allocation size from sbrk to mmap
    4444        size_t malloc_unfreed();                                                        // heap unfreed size (bytes)
     45        void malloc_stats_clear();                                                      // clear heap statistics
    4546} // extern "C"
    4647
Note: See TracChangeset for help on using the changeset viewer.