| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
#ifndef __MEMORY_LEAK_DETECTOR_H__ |
| 23 |
#define __MEMORY_LEAK_DETECTOR_H__ |
| 24 |
|
| 25 |
#include <map> |
| 26 |
#include <vector> |
| 27 |
#include "devconfig.h" |
| 28 |
|
| 29 |
#define LOG_PATH "./igd_0.log" |
| 30 |
#define HLT_PATH "./igd_0.hlt" |
| 31 |
#define MEM_LEAK_REPORT_PATH "./memory_leak_report.txt" |
| 32 |
|
| 33 |
enum MemInfoType |
| 34 |
{ |
| 35 |
MEM_INFO_TYPE_ALLOC_SYS, |
| 36 |
MEM_INFO_TYPE_ALLOC_GFX, |
| 37 |
MEM_INFO_TYPE_FREE_SYS, |
| 38 |
MEM_INFO_TYPE_FREE_GFX, |
| 39 |
MEM_INFO_TYPE_COUNT |
| 40 |
}; |
| 41 |
|
| 42 |
struct MemInfo |
| 43 |
{ |
| 44 |
MemInfoType type; |
| 45 |
std::string ptr; |
| 46 |
std::string functionName; |
| 47 |
std::string filename; |
| 48 |
std::string line; |
| 49 |
}; |
| 50 |
|
| 51 |
class MemoryLeakDetector |
| 52 |
{ |
| 53 |
public: |
| 54 |
|
| 55 |
static void Detect(int32_t memNinjaCnt, int32_t memNinjaCntGfx, Platform_t platform); |
| 56 |
}; |
| 57 |
|
| 58 |
class MemoryLeakDetectorIpl |
| 59 |
{ |
| 60 |
public: |
| 61 |
|
| 62 |
static MemoryLeakDetectorIpl *GetInstance(); |
| 63 |
|
| 64 |
void Detect(const std::string &logPath); |
| 65 |
|
| 66 |
void GenerateReport(const std::string &reportPath, const std::string &title) const; |
| 67 |
|
| 68 |
private: |
| 69 |
|
| 70 |
bool ParseLine(const std::string &line, MemInfo &memInfo) const; |
| 71 |
|
| 72 |
uint32_t GetHitNum(int32_t idx) const; |
| 73 |
|
| 74 |
private: |
| 75 |
|
| 76 |
static MemoryLeakDetectorIpl *m_instance; |
| 77 |
std::map<uint64_t, int32_t> m_memPtr; |
| 78 |
std::vector<MemInfo> m_memInfoTable; |
| 79 |
}; |
| 80 |
|
| 81 |
#endif |