Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:16:10

0001 // Tell emacs that this is a C++ source
0002 //  -*- C++ -*-.
0003 #ifndef FUN4ALL_FUN4ALLMEMORYTRACKER_H
0004 #define FUN4ALL_FUN4ALLMEMORYTRACKER_H
0005 
0006 #include "Fun4AllBase.h"
0007 
0008 #include <map>
0009 #include <string>
0010 #include <vector>
0011 
0012 class Fun4AllMemoryTracker : public Fun4AllBase
0013 {
0014  public:
0015   static Fun4AllMemoryTracker *instance()
0016   {
0017     if (mInstance) return mInstance;
0018     mInstance = new Fun4AllMemoryTracker();
0019     return mInstance;
0020   }
0021   ~Fun4AllMemoryTracker() override;
0022   void Snapshot(const std::string &trackername, const std::string &group = "");
0023   void Start(const std::string &trackername, const std::string &group = "");
0024   void Stop(const std::string &trackername, const std::string &group = "");
0025 
0026   static int GetRSSMemory();
0027   void PrintMemoryTracker(const std::string &name = "") const;
0028   std::vector<int> GetMemoryVector(const std::string &name) const;
0029 
0030  private:
0031   Fun4AllMemoryTracker();
0032   static std::string CreateFullTrackerName(const std::string &trackername, const std::string &group = "");
0033   static Fun4AllMemoryTracker *mInstance;
0034   std::map<std::string, std::vector<int>> mMemoryTrackerMap;
0035   std::map<std::string, int> mStartMem;
0036 };
0037 
0038 #endif