#1 Re: mORMot 2 » mormot.core.text.ObjectToJson & PatchCode » 2023-08-09 08:30:48

Hi Arnaud,

We've tried your fixes and they work perfectly.

Measured performance impact on serialize and deserialize (1.000.000 times repeat in a separate performance project, with NOPATCHVMT, i7-12700H, Win10):
- of plain Integer is 1% faster with NOPATCHVMT
- of large record (50 vars) is 1% faster with NOPATCHVMT

We are using the latest version of Delphi (11.4) on Windows 10 embedded.

We are very thankful for your quick and perfect solution, the donation is on it's way.

#2 mORMot 2 » mormot.core.text.ObjectToJson & PatchCode » 2023-08-08 13:05:11

Anze
Replies: 4

Hi,

we just started implementing ObjectToJson from the mORMot 2 library, which works insanely fast btw, and we encountered on an issue that makes the solution unusable for us, either we have a memory leak (with our quick and dirty solution - details below) or memory check fails.

We are writing our software in a business area where code part of the executable in the ram has to be periodically checked and checksum has to match all the time or the software has to lock itself till the next restart.

ObjectToJson causes the call to PatchCode, which changes the code part in the memory and so the memory check fails.

We have at least two options to resolve this:
a) let our memory check module know which Bytes where changed and ignore them (we would need a waiver from the certificate agency to do this, so not the best solution for us)
b) disable the RTTI optimization that is caused by ObjectToJson
c) ?

We are looking for somebody who would help us with b) (or c) ) (the donation is implicit in this case)

PS: our quick and dirty solution, which causes memory leaks:

in procedure TRttiCustom.SetValueClass(aClass: TClass; aInfo: PRttiInfo);

//  vmt := Pointer(PAnsiChar(aClass) + vmtAutoTable);
//  if vmt^ = nil then
//    PatchCodePtrUInt(pointer(vmt), PtrUInt(self), {leaveunprotected=}true);
//  if vmt^ <> self then
//    raise ERttiException.CreateUtf8(
//      '%.SetValueClass(%): vmtAutoTable set to %', [self, aClass, vmt^]);

and

in function TRttiCustomList.DoRegister(Info: PRttiInfo): TRttiCustom;

//  if FindType(Info) <> result then // paranoid check
//    raise ERttiException.CreateUtf8('%.DoRegister(%)?', [self, Info.RawName]);

Board footer

Powered by FluxBB