ACAV f0ba4b7c9529
Abstract Syntax Tree (AST) visualization tool for C, C++, and Objective-C
Loading...
Searching...
No Matches
acav::MemoryProfiler Class Reference

Cross-platform memory profiling utility. More...

#include <MemoryProfiler.h>

Public Types

using LogCallback = std::function<void(const QString &message)>

Static Public Member Functions

static void checkpoint (const QString &label)
 Log current memory usage with a label.
static long getPeakMemoryMB ()
 Get current peak memory usage in MB (maximum RSS since process start).
static long getCurrentMemoryMB ()
 Get current actual memory usage in MB (current RSS).
static void setLogCallback (LogCallback callback)
 Set a callback for memory log messages (GUI hook).

Detailed Description

Cross-platform memory profiling utility.

Provides lightweight memory usage tracking without external tools. Uses getrusage() on Unix/macOS and GetProcessMemoryInfo() on Windows. Enable via config: debug/enableMemoryProfiling=true

Definition at line 38 of file MemoryProfiler.h.

Member Typedef Documentation

◆ LogCallback

using acav::MemoryProfiler::LogCallback = std::function<void(const QString &message)>

Definition at line 40 of file MemoryProfiler.h.

Member Function Documentation

◆ checkpoint()

void acav::MemoryProfiler::checkpoint ( const QString & label)
static

Log current memory usage with a label.

Parameters
labelDescriptive label for this checkpoint

Definition at line 128 of file MemoryProfiler.cpp.

References getCurrentMemoryMB(), and getPeakMemoryMB().

Referenced by acav::MainWindow::loadCompilationDatabase(), and acav::AstExtractorRunner::run().

◆ getCurrentMemoryMB()

long acav::MemoryProfiler::getCurrentMemoryMB ( )
static

Get current actual memory usage in MB (current RSS).

Returns
Current resident set size in megabytes, or -1 if unavailable

Definition at line 91 of file MemoryProfiler.cpp.

Referenced by checkpoint().

◆ getPeakMemoryMB()

long acav::MemoryProfiler::getPeakMemoryMB ( )
static

Get current peak memory usage in MB (maximum RSS since process start).

Returns
Peak resident set size in megabytes, or -1 if unavailable

Definition at line 65 of file MemoryProfiler.cpp.

Referenced by checkpoint().

◆ setLogCallback()

void acav::MemoryProfiler::setLogCallback ( LogCallback callback)
static

Set a callback for memory log messages (GUI hook).

Definition at line 56 of file MemoryProfiler.cpp.


The documentation for this class was generated from the following files: