MCPcopy Create free account
hub / github.com/beefytech/Beef / ShowMemoryUsage

Function ShowMemoryUsage

IDEHelper/DebugManager.cpp:535–581  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

533//static _CrtMemBlockHeader* __acrt_last_block;
534
535void ShowMemoryUsage()
536{
537#ifdef BF_PLATFORM_WINDOWS
538 PROCESS_MEMORY_COUNTERS processMemCounters;
539 processMemCounters.cb = sizeof(PROCESS_MEMORY_COUNTERS);
540 GetProcessMemoryInfo(GetCurrentProcess(), &processMemCounters, sizeof(PROCESS_MEMORY_COUNTERS));
541 OutputDebugStrF("WorkingSet : %dk\n", (int)(processMemCounters.WorkingSetSize / 1024));
542 OutputDebugStrF("VirtualMem : %dk\n", (int)(processMemCounters.PagefileUsage/1024));
543
544 static bool hasCheckpoint = true;
545 _CrtMemState memState;
546 _CrtMemCheckpoint(&memState);
547 //OutputDebugStrF("Crt Size: %dk\n", (int)(memState.lTotalCount / 1024));
548
549 char* names[6] = { "_FREE_BLOCK", "_NORMAL_BLOCK", "_CRT_BLOCK", "_IGNORE_BLOCK", "_CLIENT_BLOCK", "_MAX_BLOCKS" };
550 for (int i = 0; i < 5; i++)
551 {
552 OutputDebugStrF("%s : %d %dk\n", names[i], memState.lCounts[i], memState.lSizes[i] / 1024);
553 }
554
555#ifdef _DEBUG
556// int64 totalCrtSize = 0;
557// int64 totalUseCrtSize = 0;
558// _CrtMemBlockHeader* blockPtr = memState.pBlockHeader;
559// while (blockPtr != NULL)
560// {
561// totalCrtSize += blockPtr->_data_size;
562// if (blockPtr->_block_use != _FREE_BLOCK)
563// totalUseCrtSize += blockPtr->_data_size;
564// blockPtr = blockPtr->_block_header_next;
565// }
566// OutputDebugStrF("Crt Size: %dk Used: %dk\n", (int)(totalCrtSize / 1024), (int)(totalUseCrtSize / 1024));
567#endif
568
569 _HEAPINFO heapInfo = {0};
570 int64 heapSize = 0;
571
572 int heapStatus;
573 while ((heapStatus = _heapwalk(&heapInfo)) == _HEAPOK)
574 {
575 heapSize += (int64)heapInfo._size;
576 }
577 OutputDebugStrF("WALKED HEAP SIZE: %dk\n", heapSize / 1024);
578
579 //_CrtMemDumpStatistics(&memState);
580#endif
581}
582
583/*void* TestHeapAlloc(HANDLE hHeap, DWORD dwFlags, SIZE_T dwBytes)
584{

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected