0

I am using RAD Studio 10.2.3.

I am trying to use FastMM4 to find memory leaks in my C++Builder 64-bit application.

So I downloaded FastMM4. I have the latest version 4.993.

The problem is that some part of the code are a little bit obsolete and need to be adjusted.

For example, I needed to recompile FastMM_FullDebugMode.dll. It is OK for this one because the source code is included.

The problem is that the DLL works with a .lib file, which unfortunately is for a 32-bit application.

I tried anyway, but I am getting the error message below:

[ilink64 Error] Fatal: Invalid object file 'FASTMM_FULLDEBUGMODE.LIB'

I am pretty sure it is because I need a 64-bit library, which is .a (not .lib).

So, I tried to find FastMM_FullDebugMode.lib source code to recompile for a 64-bit application. But I cannot find it on GitHub.

Does somebody know where I can find and download that source code?

I confirm that the library file issue is resolved! But I am running into another one. I am getting the following popup error message:

"FastMM4 cannot install since memory has already been allocated through the default memory manager. FastMM4.pas MUST be the first unit in your project's dpr file."

I am sure that I followed all the steps. In my project "Options > Build order" I put FastMM4Messages,pas first, then FastMM4.pas as written in the documentation. I also added: USEOBJ("FastMM4BCB.cpp"); in my project main file

So, how to fix this error?


After verification, I have to conclude that FastMM$ cannot work with C++ Builder 10.2. I don't know it can either work with previous versions of C++ Builder. I noticed some functions which are used in FastMM4 and cannot work with C++ Builder:

  1. IsMemoryManagerSet is always true in C++ Builder https://docwiki.embarcadero.com/Libraries/Tokyo/en/System.IsMemoryManagerSet

  2. GetHeapStatus is deprecated https://docwiki.embarcadero.com/Libraries/Tokyo/en/System.GetHeapStatus

I tried to replace IsMemoryManagerSet by a local variable and GetHeapStatus by GetMemoryManagerState, but that did not resolve the issue. Cannot have FastMM4 work.

So, most simple solution: Does anybody know another free memory leaks detection application I can use in C++ Builder 10.2.3? Something which really works?

Louis
  • 75
  • 6
  • There is only 1 source code. Make sure you are compiling it as a 64-bit DLL, not a 32-bit DLL. You can control that in the project settings, make sure 64-bit is added to the project as a target platform. As for the import library, if the compiler doesn't generate one automatically, you can always use [`MKEXP.EXE`](https://docwiki.embarcadero.com/RADStudio/en/MKEXP.EXE,_the_64-bit_Windows_Import_Library_Tool_for_C%2B%2B) to make one manually from the DLL itself. – Remy Lebeau Nov 03 '21 at 02:46
  • It is difficult to mistake the target platform when you are compiling the dll! – Louis Nov 03 '21 at 13:58
  • I think what I need to do is to us MKEXP.EXE to generate the correct lib file! – Louis Nov 03 '21 at 13:58
  • well, you need a 64bit DLL compiled first. MKEXP only works on 64bit DLLs. [`IMPLIB.EXE`](https://docwiki.embarcadero.com/RADStudio/en/IMPLIB.EXE,_the_Import_Library_Tool_for_Win32) is the equivalent for 32bit DLLs. – Remy Lebeau Nov 03 '21 at 14:28
  • OK. It seems to be working after generating the 64 lib using MKEXP.EXE I also needed to replace this line in FastMM4BCB.cpp: #pragma link "FastMM_FullDebugMode.lib" by #pragma comment(lib, "FastMM_FullDebugMode") I think it is more generic – Louis Nov 03 '21 at 14:28
  • I confirm that the library file issue is resolved! But I am running into another one. I am getting the following popup error message: "FastMM4 cannot install since memory has already been allocated through the default memory manager. FastMM4.pas MUST be the first unit in your project's dpr file." I am sure that I followed all the steps. In my project "Options > Build order" I put FastMM4Messages,pas first, then FastMM4.pas as written in the documentation. I also added: USEOBJ("FastMM4BCB.cpp"); in my project main file So, how to fix this error? – Louis Nov 03 '21 at 15:28

0 Answers0