Skip to content

Commit d0386a7

Browse files
author
Michidu
committed
Fixed high memory usage
1 parent eedfef1 commit d0386a7

1 file changed

Lines changed: 31 additions & 1 deletion

File tree

version/Core/Private/PDBReader/PDBReader.cpp

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include "PDBReader.h"
22

33
#include <fstream>
4-
#include <atlbase.h>
54

65
#include <Logger/Logger.h>
76
#include <Tools.h>
@@ -11,6 +10,37 @@
1110

1211
namespace API
1312
{
13+
template <typename T>
14+
class ScopedDiaType
15+
{
16+
public:
17+
ScopedDiaType() : _sym(nullptr)
18+
{
19+
}
20+
21+
ScopedDiaType(T* sym) : _sym(sym)
22+
{
23+
}
24+
25+
~ScopedDiaType()
26+
{
27+
if (_sym != nullptr)
28+
_sym->Release();
29+
}
30+
31+
T** ref() { return &_sym; }
32+
T** operator&() { return ref(); }
33+
T* operator->() { return _sym; }
34+
operator T*() { return _sym; }
35+
void Attach(T* sym) { _sym = sym; }
36+
37+
private:
38+
T* _sym;
39+
};
40+
41+
template <typename T>
42+
using CComPtr = ScopedDiaType<T>;
43+
1444
void PdbReader::Read(const std::wstring& path, std::unordered_map<std::string, intptr_t>* offsets_dump,
1545
std::unordered_map<std::string, BitField>* bitfields_dump)
1646
{

0 commit comments

Comments
 (0)