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,861 other subscribers

Archive for 2021

“Unexpected Memory Leak” after “MyTestApplication.exe: Memory Leak Detected”

Posted by jpluimers on 2021/07/28

Sometimes after a regular FastMM memory leak test report you get a dialog like this:

---------------------------
Unexpected Memory Leak
---------------------------
An unexpected memory leak has occurred. The unexpected small block leaks are:

61 - 68 bytes: Unknown x 1
---------------------------
OK   
---------------------------

The normal FastMM memory leak reporting dialog looks like this:

---------------------------
MyTestApplication.exe: Memory Leak Detected
---------------------------
...
Note: Memory leak detail is logged to a text file in the same folder as this application. To disable this memory leak check, undefine "EnableMemoryLeakReporting".
---------------------------
OK   
---------------------------

Searching for “Unexpected Memory Leak” in RTL or FastMM code did not reveal results, but that might be me not doing a proper search.

One big problem is that the regular memory leak dialog is being suppressed by setting SuppressMessageBoxes to True (see for instance my blog post Application shutdown: wait for all threads to terminate or not? or [WayBack] delphi – Generating a FASTMM report WITHOUT the shutdown dialog – Stack Overflow).

However the “Unexpected Memory Leak” message box is always shown.

Research

Location of the error message caption

  • GETMEM.INC has an identifier LeakMessageTitle:
    LeakMessageTitle: _PAnsiChr = 'Unexpected Memory Leak';
  • Unlike FastMM4.pas, GETMEM.INC does not take into account SuppressMessageBoxes.
  • Like FastMM4.pas, GETMEM.INC does take into account ReportMemoryLeaksOnShutdown.

More on GETMEM.INC: [WayBack] delphi – Reporting memory leaks on shutdown with a console application – Stack Overflow

Versioned FastMM4.pas.

Complicating the hunt

Not all allocations go via the memory manager. A complicating factor is that:

  • ALL TMonitor.Create allocations go through SysAllocMem:
class function TMonitor.Create: PMonitor;
begin
  if CacheLineSize = 0 then
    AtomicExchange(CacheLineSize, GetCacheLineSize);
  if (CPUCount > 1) and (FDefaultSpinCount = 0) then
    AtomicExchange(FDefaultSpinCount, 1000);
  if CacheLineSize > SizeOf(Result^) then
    Result := SysAllocMem(CacheLineSize)
  else
    Result := SysAllocMem(SizeOf(Result^));
  Result.FSpinCount := FDefaultSpinCount;
end;
  • ALL TMonitor.Destroy deallocations go through SysFreeMem:
procedure TMonitor.Destroy;
begin
  if (MonitorSupport <> nil) and (FLockEvent <> nil) then
    MonitorSupport.FreeSyncObject(FLockEvent);
  SysFreeMem(@Self);
end;

Debugging this is easiest to set a breakpoint in the FastMM4.pas finalization section enabling a breakpoint group that has breakpoints on these methods inside GETMEM.INC:

  • function SysGetMem(Size: NativeInt): Pointer;
  • function SysFreeMem(P: Pointer): Integer;
  • function SysReallocMem(P: Pointer; Size: NativeInt): Pointer;
  • function SysAllocMem(Size: NativeInt): Pointer;

For inspecting for instance an asm construct like TSmallPoolBlockPoolHeader[edx], use a conversion PSmallBlockPoolHeader(Pointer(EDX))^,r

Poor mans shotgun approach

This will hide all the SysAllocMem related leaks:

unit FastMM4WrapperUnit;

interface

{$ifdef UseFastMM4}
uses
  FastMM4,
  FastMM4Messages;
{$endif UseFastMM4}

implementation

initialization
//
finalization
// Disable GETMEM.INC reports that neglect SuppressMessageBoxes and NoErrMsg; this will effectively hide the leak as GETMEM.INC also does not write the leaks to a log file
{$ifdef UseFastMM4}
  if SuppressMessageBoxes then
  begin
    {$WARN SYMBOL_PLATFORM OFF} NoErrMsg := True {$WARN SYMBOL_PLATFORM ON}; // no ShowMessage from the RTL (except for memory leaks)
    ReportMemoryLeaksOnShutdown := False; // No ShowMessage from the RTL in the GETMEM.INC teardown
  end;
{$endif UseFastMM4}
end.

IsConsole: needs linker option

Note that I tried embedding this in the then portion, but enabling IsConsole fails:

    IsConsole := True; // can only force run-time error messages to be written to the console if the "Project/Options/Linking/Generate console application" is set.

The reason is that this does not allocate a console handle, so you really need to ensure the linker has allocated a console for you by enabling Project/Options/Linking/Generate console application (or option DCC_ConsoleTarget in the .dproj file)

For more details, see my post console – When is System.IsConsole true in Delphi? – Stack Overflow.

–jeroen

Posted in Conference Topics, Conferences, Delphi, Development, Event, FastMM, Software Development | Leave a Comment »

Profiler and Memory Analysis Tools for Delphi – Stack Overflow

Posted by jpluimers on 2021/07/27

Lots of interesting profilers in [WayBack] Profiler and Memory Analysis Tools for Delphi – Stack Overflow:

--jeroen

Posted in Delphi, Development, Software Development | 2 Comments »

Listing information on all active interfaces on MacOS part 2: adding DHCP/BOOTP and routing details

Posted by jpluimers on 2021/07/27

This is a continuation of yesterdays

Listing information on all active interfaces on MacOS part 1: getting the active interface names.

It is based on ideas in these StackExchange posts:

I threw most of the implementation details in the ideas away, as they were way to much based on empirical trial and error, than proper research.

So I tried doing the research and came up with the things below.

Getting the IPv4 address and DHCP/BOOTP information of a NIC

By using the ipconfig command, you can get specific details for a NIC like an IPv4 (with the getifaddr) or DHCP (with the getpacket option to get the latest DHCP packet):

for i in $(ifconfig -l -u); do if ifconfig $i | grep -q "status: active" ; then echo $i; fi; done | xargs -n1 -I_nic_ sh -c 'echo "_nic_: $(ipconfig getifaddr _nic_)"'

or DHCP/BOOTP:

for i in $(ifconfig -l -u); do if ifconfig $i | grep -q "status: active" ; then echo $i; fi; done | xargs -n1 -I_nic_ sh -c 'echo "_nic_: $(ipconfig getpacket _nic_)"'

The latter returns a very long list, which I wanted to shorten into a more readable format.

ipconfig syntax

You can find more information in the [Archive.is] ipconfig(8) [osx man page] / [WayBack] ipconfig Man Page – macOS – SS64.com excerpt:

Read the rest of this entry »

Posted in *nix, *nix-tools, Apple, bash, Development, DNS, ifconfig, Mac OS X / OS X / MacOS, Power User, Scripting, Software Development | Leave a Comment »

Updating a Unifi Controller (either a Cloud Key, or a local installation like a VM)

Posted by jpluimers on 2021/07/27

Note that by now, Unifi Controller is usually named Unifi Network Management Controller (somewhere in between it was called Unify Network Controller).

You can either run a local installation on a Linux box (usually Ubuntu), for instance the CloudKey ESXi Appliance, or from a Cloud Key (if you do, do not get a version 1 Cloud Key; too much SD card and other hardware trouble)

Steps to update both the Unifi Controller Firmware (Cloud Key only) and the Unifi Controller software (both Cloud Key and local installation) are below.

I am assuming that 192.168.71.50 is the IP address of your Cloud Key, and for brevity, I included few screenshots, but opted for URLs.

Devices steps

  1. Logon to your Cloud Key at https://192.168.71.50:8443/manage
  2. Go to the devices page https://192.168.71.50:8443/manage/site/default/devices/1/50/uap
  3. Ensure the filter is “APs” (either through the dropdown when your tab is narrow, or the button when the tab is wide)
  4. Press the “Start rolling update” button.
  5. Confirm the rolling update
  6. Wait for the rolling update to finish

Screenshots for selecting “APs” with narrow and wide tab widths:

 

Read the rest of this entry »

Posted in Cloud Key, Network-and-equipment, Power User, Unifi-Ubiquiti | Leave a Comment »

Getting to the Amazon.de chat

Posted by jpluimers on 2021/07/26

  1. Visit https://smile.amazon.de/gp/help/customer/contact-us/ref=hp_abgt_cu_cu?nodeId=508510
  2. Click “Prime und Sonstiges”
  3. In the “Bitte wählen Sie ein Thema” selector, choose “Andere, nicht auf eine Bestellung bezogene Frage”
  4. In the “Bitte grenzen Sie Ihr Anliegen ein” selector, choose “Sonstige Fragen”
  5. Now a “Chat” button appears:

–jeroen

Posted in Amazon.com/.de/.fr/.uk/..., Cloud, Infrastructure, Power User | Leave a Comment »

Dani Donovan on Twitter: “therapist: and what do we do when we’re feeling stressed? me: stop making plans, avoid text messages, and accidentally alienate myself from all of my friends therapist: no”

Posted by jpluimers on 2021/07/26

ADHD is hard. Dani Donovan has some great resources on it.

[WayBack] Dani Donovan on Twitter: ”
therapist: and what do we do when we’re feeling stressed?
me: stop making plans, avoid text messages, and accidentally alienate myself from all of my friends
therapist: no”

Via: [WayBack] Ian Coldwater 📦💥✨ on Twitter: “For extra fun, delete your Twitter and avoid messages from your friends across Signal and 15 different Slack teams… “

Related:

It also taught me about Twitter: Moments – Wikipedia (which have been there for way longer than I thought: 2015! [WayBack] Moments, the best of Twitter in an instant)

–jeroen

Read the rest of this entry »

Posted in About, LifeHacker, Personal, Power User | Leave a Comment »

Maybe time again to look at Boxstarter

Posted by jpluimers on 2021/07/26

I wrote a tiny post about Boxstarter a long time ago, so maybe it is time to look at it again.

By now, there are way more scripts, so here are some links:

Related: Boxstarter: quickly setup a machine with just a Gist

–jeroen

Posted in Boxstarter, Chocolatey, Power User, Windows | Leave a Comment »

Android: Island – app freezing, privacy protection, parallel accounts

Posted by jpluimers on 2021/07/23

Requires admin privileges, but can be worth your effort: [WayBack] [APP][5.0+][BETA] Island – app freezing, pri… | Android Development and Hacking

“Island” is a sandbox environment to clone selected apps and isolate them from accessing your personal data outside the sandbox (including call logs, contacts, photos and etc) even if related permissions are granted. Device-bound data is still accessible (SMS, IMEI and etc).
Isolated app can be frozen on demand, with launcher icon vanish and its background behaviors completely blocked.

Via:

–jeroen

Posted in Android, Android Devices, Development, Mobile Development, Power User | Leave a Comment »

Microsoft Rosebud was MSDAIPP – Wikipedia

Posted by jpluimers on 2021/07/23

On an old system, I found some x86 installers with names like RbudLR.cab, RosebudMUI.msiRosebudMUI.xmlsetup.xml.

They appeared to be the (now deprecated and never released as x64): MSDAIPP – Wikipedia (Microsoft Data Access Internet Publishing Provider).

Searching for RosebudMUI many returned detection scams like solvusoft, but somewhere further down was this only meaningful result: [WayBack] What is the RosebudMUI AddOn in Visio 2007?

–jeroen

Posted in Office, Office 2010, Power User, Windows | Leave a Comment »

PostNL International Parcel Tracking

Posted by jpluimers on 2021/07/23

When local tracking fails use PostNL International Parcel Tracking

Convert the URL

For instance when this happens:

–jeroen

Read the rest of this entry »

Posted in LifeHacker, Power User | Leave a Comment »