Reminder: When you need help, please be specific and remember to tell us:

Reminder: When you need help, please be specific and remember to tell us:

– Version of Delphi incl. ver.no (D5, D2006, XE3, XE8, Seattle 10.0.x, Berlin 10.1.x, Tokyo 10.2.x, etc.)

– SKU (Community, Pro, Enterprise, Architect)

– Platform (Windows, iOS, Android, Linux)

– Tech (console, VCL, FMX, etc)

– Database platform (ADO, dbExpress, FireDAC, etc)

– Database (MSSQL, MySQL, Oracle, SQLite, etc)

Also see: https://plus.google.com/+LarsFosdal/posts/NarwjyzC4rN

Where do you place your unit uses?

Where do you place your unit uses?

Over the years, I’ve come to preferring to place my uses in the Interface section only, even if its types, constants or methods only are used in the implementation section.

What is your practice, and why do you prefer one pattern over the others – or why would you recommend against one of these patterns?

unit Test;

interface

uses

ThisUnit, ThatUnit;

implementation

end.

vs

unit Test;

interface

uses

ThisUnit;

implementation

uses

ThatUnit;

end.

Generic surprises

Generic surprises

1. The generic type is constrained, but cannot be used for class references?

type

TBase = class

procedure NothingAbstractHere;

constructor Create; virtual;

end;

TGenericWrapper = class

type

TBaseClass = class of TB; <– [dcc32 Error]: E2021 Class type required

end;

Is there any logical reason for why this should not be possible?

2. Constructing an instance from a generic type does not flag construction of a class with unimplemented virtual abstract methods. This one I can understand, but it still is annoying. I guess I could factory functions to work around it.

This piece of code is Windows only:

This piece of code is Windows only:

function MemoryUsed: cardinal; inline;

var

MMS: TMemoryManagerState;

Block: TSmallBlockTypeState;

begin

GetMemoryManagerState(MMS);

Result := MMS.TotalAllocatedMediumBlockSize + MMS.TotalAllocatedLargeBlockSize;

for Block in MMS.SmallBlockTypeStates

do Result := Result + (Block.UseableBlockSize * Block.AllocatedBlockCount);

end;

Is there something that is available on other platforms (POSIX) that can give me an idea of how much memory the app is using, without calling native OS functions?