Opening XPS document in .Net causes a memory leak

Well, I found it. It IS a bug in the framework and to work around it you add a call to UpdateLayout. Using statement can be changed to the following to provide a fix; Using XPSItem As New Windows.Xps.Packaging.XpsDocument(PathToTestXps, System.IO.FileAccess.Read) Dim FixedDocSequence As Windows.Documents.FixedDocumentSequence Dim DocPager As Windows.Documents.DocumentPaginator FixedDocSequence = XPSItem.GetFixedDocumentSequence DocPager = FixedDocSequence.DocumentPaginator DocPager.ComputePageCount() … Read more

intrinsic memcmp

Note that the repz cmpsb routine might not be faster than glibc’s memcmp. In my tests, in fact, it’s never faster, even when comparing just a few bytes. See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43052

How to get the starting/base address of a process in C++?

Here’s another way, written in Visual Studio 2015 but should be backwards compatible. void GetBaseAddressByName(DWORD processId, const _TCHAR *processName) { _TCHAR szProcessName[MAX_PATH] = _TEXT(“<unknown>”); HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processId); if (NULL != hProcess) { HMODULE hMod; DWORD cbNeeded; if (EnumProcessModulesEx(hProcess, &hMod, sizeof(hMod), &cbNeeded, LIST_MODULES_32BIT | LIST_MODULES_64BIT)) { GetModuleBaseName(hProcess, hMod, szProcessName, sizeof(szProcessName) / … Read more