The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,860 other subscribers

Note that the Delphi superobject library has changed to “not maintained” in december 2018, has problems with large address aware

Posted by jpluimers on 2019/05/02

A while ago I found out the [WayBack] not maintained status · hgourvest/superobject@f1c42db · GitHub.

This means you should not use the [WayBack] superobject JSON library in Delphi any more: there won’t be any fixes.

Many people use it, especially because it used to be much more stable than the built-in JSON support of Delphi.

One breaking issue in superobject is the lack of large address space support: due to the pointer calculations in various places, it does not support pointers above the 2 gibibyte boundary as filed in the 2016 [WayBack] Issues with {$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE} · Issue #22 · hgourvest/superobject · GitHub

This gives problems in at least this case:

  • enabling {$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE} (in older Delphi 7 through 2006 also versions this was {$SetPEFlags $20})
  • using top-down memory allocation, for instance by:
    • a user setting HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Memory Management value AllocationPreference to hex value 00100000
    • using FastMM4 with the (default) {$define AlwaysAllocateTopDown} setting

Example registry file and batch file to enable top-down memory (reboot afterwards):

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management]
"AllocationPreference"=dword:00100000

Command to view:

reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" | findstr "AllocationPreference"

Command to enable:

reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v AllocationPreference /t REG_DWORD /d 00100000 /f

Command to disable:

reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v AllocationPreference /f

Large Address Aware is a nightmare

Be very very very careful with this, and by enabling Large Address Aware to your executables, as many times they can load 3rd party libraries that often are beyond your control.

Even if there is a slight chance that your code is being used with Large Address Aware enabled, then follow guidelines line in [WayBack] windows – Unit Testing for x86 LargeAddressAware compatibility – Stack Overflow

Summary of [WayBack] memory – Drawbacks of using /LARGEADDRESSAWARE for 32 bit Windows executables? – Stack Overflow:

blindly applying the LargeAddressAware flag to your 32bit executable deploys a ticking time bomb!

by setting this flag you are testifying to the OS:

yes, my application (and all DLLs being loaded during runtime) can cope with memory addresses up to 4 GB.
so don’t restrict the VAS for the process to 2 GB but unlock the full range (of 4 GB)”.

but can you really guarantee?
do you take responsibility for all the system DLLs, microsoft redistributables and 3rd-party modules your process may use?

Edit 20240628

Earlier this year, the SuperObject Delphi library got archived on GitHub. Definitely unmaintained: [Wayback/Archive] GitHub – hgourvest/superobject: This repository has been archived by the owner on Feb 27, 2024. It is now read-only.

The XSuperObject library mentioned below in a comment has not been maintained for 4 years either ( [Wayback/Archive] GitHub – onryldz/x-superobject: Delphi Cross Platform Rapid JSON: “vkrapotkin Now ParseFromFile can read UTF8-BOM files (#136) 2d3ec01 · 2020-12-09”), so I wonder what alternatives are still available.

--jeroen

4 Responses to “Note that the Delphi superobject library has changed to “not maintained” in december 2018, has problems with large address aware”

  1. Jacek's avatar

    Jacek said

    I’d like to inform you that on Firefox and Chrome it is truncated, see:

  2. Rommel's avatar

    Rommel said

    https://github.com/onryldz/x-superobject is still actively maintained but I do not know if it suffers the same issues

    • jpluimers's avatar

      jpluimers said

      Sorry that I missed your comment earlier on.

      It looks like that library too went unmaintained as of 2020.

      Too bad: good JSON support in Delphi is important.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.