mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-29 16:25:42 +00:00
mem report cleanups
ditch reporting ram adresses. it complicates comparisons remove console filtering spool report std::atexit sort report by magnitude, then frequency
This commit is contained in:
parent
2a9aa3a9d5
commit
aeea20f078
2 changed files with 18 additions and 30 deletions
|
|
@ -256,12 +256,6 @@ S32 TorqueMain(S32 argc, const char **argv)
|
||||||
if( StandardMainLoop::requiresRestart() )
|
if( StandardMainLoop::requiresRestart() )
|
||||||
Platform::restartInstance();
|
Platform::restartInstance();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if defined( TORQUE_ENABLE_ASSERTS ) && !defined( TORQUE_DISABLE_MEMORY_MANAGER )
|
|
||||||
Memory::shutdown();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Return.
|
// Return.
|
||||||
return StandardMainLoop::getReturnStatus();
|
return StandardMainLoop::getReturnStatus();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,13 @@ namespace Memory
|
||||||
U32 total = 0;
|
U32 total = 0;
|
||||||
} memLog[MaxAllocs];
|
} memLog[MaxAllocs];
|
||||||
|
|
||||||
|
bool sortMemReports(memReport const& lhs, memReport const& rhs)
|
||||||
|
{
|
||||||
|
if (lhs.total != rhs.total)
|
||||||
|
return lhs.total > rhs.total;
|
||||||
|
return lhs.count > rhs.count;
|
||||||
|
}
|
||||||
|
|
||||||
void init()
|
void init()
|
||||||
{
|
{
|
||||||
if (initialized) return;
|
if (initialized) return;
|
||||||
|
|
@ -100,7 +107,7 @@ namespace Memory
|
||||||
std::tm* localTime = std::localtime(&now);
|
std::tm* localTime = std::localtime(&now);
|
||||||
std::strftime(gLogFilename, sizeof(gLogFilename), "memlog_%Y-%m-%d_%H-%M-%S.txt", localTime);
|
std::strftime(gLogFilename, sizeof(gLogFilename), "memlog_%Y-%m-%d_%H-%M-%S.txt", localTime);
|
||||||
|
|
||||||
//std::atexit(shutdown);
|
std::atexit(shutdown);
|
||||||
}
|
}
|
||||||
|
|
||||||
void shutdown()
|
void shutdown()
|
||||||
|
|
@ -113,14 +120,7 @@ namespace Memory
|
||||||
|
|
||||||
std::fprintf(log, "\n--- Memory Leak Report ---\n");
|
std::fprintf(log, "\n--- Memory Leak Report ---\n");
|
||||||
|
|
||||||
U32 start = 0;
|
for (U32 curRep = 0; curRep < allocCount; ++curRep)
|
||||||
U32 stop = allocCount;
|
|
||||||
if (gFromScript) //filter out the bits from console
|
|
||||||
{
|
|
||||||
start = 6;
|
|
||||||
stop = allocCount - 8;
|
|
||||||
}
|
|
||||||
for (U32 curRep = start; curRep < stop; ++curRep)
|
|
||||||
{
|
{
|
||||||
if (allocList[curRep].ptr != nullptr)
|
if (allocList[curRep].ptr != nullptr)
|
||||||
{
|
{
|
||||||
|
|
@ -151,16 +151,16 @@ namespace Memory
|
||||||
|
|
||||||
if (SymFromAddr(process, addr, 0, symbol)) {
|
if (SymFromAddr(process, addr, 0, symbol)) {
|
||||||
if (SymGetLineFromAddr64(process, addr, &displacement, &line)) {
|
if (SymGetLineFromAddr64(process, addr, &displacement, &line)) {
|
||||||
std::sprintf(stack, " [%d] %s - %s:%lu (0x%0llX)\n",
|
std::sprintf(stack, " [%d] %s - %s:%lu\n",
|
||||||
curStack, symbol->Name, line.FileName, line.LineNumber, symbol->Address);
|
curStack, symbol->Name, line.FileName, line.LineNumber);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
std::sprintf(stack, " [%d] %s - ???:??? (0x%0llX)\n",
|
std::sprintf(stack, " [%d] %s - ???:???\n",
|
||||||
curStack, symbol->Name, symbol->Address);
|
curStack, symbol->Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
std::sprintf(stack, " [%d] ??? - 0x%0llX\n", curStack, addr);
|
std::sprintf(stack, " [%d] ???\n", curStack);
|
||||||
}
|
}
|
||||||
report += stack;
|
report += stack;
|
||||||
}
|
}
|
||||||
|
|
@ -177,13 +177,7 @@ namespace Memory
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (report.find("getDocsLink") != std::string::npos)
|
for (U32 oldRep = 0; oldRep < curRep; ++oldRep)
|
||||||
//{
|
|
||||||
// //known issue. one off allocation
|
|
||||||
// memLog[curRep].skip = true;
|
|
||||||
//}
|
|
||||||
|
|
||||||
for (U32 oldRep = start; oldRep < curRep; ++oldRep)
|
|
||||||
{
|
{
|
||||||
if (!memLog[oldRep].skip && (memLog[oldRep].report.find(report) != std::string::npos))
|
if (!memLog[oldRep].skip && (memLog[oldRep].report.find(report) != std::string::npos))
|
||||||
{
|
{
|
||||||
|
|
@ -202,10 +196,10 @@ namespace Memory
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
std::sort(memLog, memLog + allocCount, &sortMemReports);
|
||||||
for (U32 ntry = start; ntry < stop; ++ntry)
|
for (U32 ntry = 0; ntry < allocCount; ++ntry)
|
||||||
{
|
{
|
||||||
if (!memLog[ntry].skip)
|
if (!memLog[ntry].skip /* && (memLog[ntry].count>9 || memLog[ntry].total >1023)*/) //unrem to focus on large leaks only -BJR
|
||||||
{
|
{
|
||||||
std::fprintf(log, "Leak-count[%i]total[%i]:%s", memLog[ntry].count, memLog[ntry].total, memLog[ntry].report.c_str());
|
std::fprintf(log, "Leak-count[%i]total[%i]:%s", memLog[ntry].count, memLog[ntry].total, memLog[ntry].report.c_str());
|
||||||
memLog[ntry].report.clear();
|
memLog[ntry].report.clear();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue