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

Archive for the ‘Delphi’ Category

Delphi dcc32 error E2506 Method of parameterized type declared in interface section must not use local symbol ‘TExceptionThread`1’

Posted by jpluimers on 2019/07/25

Need to check on this compiler error that you can solve by moving the generic class TExceptionThread<T> from the implementation section of a unit to the interface section.

[dcc32 Error] Test.ExceptionLogging.pas(246): E2506 Method of parameterized type declared in interface section must not use local symbol 'TExceptionThread`1'

My gut feeling is that that this either has to do with RTTI generation, or is a limitation of the compiler.

I need to trim that one done since it does not match any of these:

–jeroen

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

delphi – Why variables are declared as TStrings and created as TStringList? – Stack Overflow

Posted by jpluimers on 2019/07/24

Blast from the past: [WayBackdelphi – Why variables are declared as TStrings and created as TStringList? – Stack Overflow

Q

Why variables are declared as TStrings and created as TStringList?

A

Because that way you could put another TStrings descendant in the SL variable (I’d probably call that Strings, not SL).

In your case, that is moot, since the logic around SL contains the creation of a TStringList and no external assignment or parameter parsing.

But if you ever split the logic away from the assignment, then you could benefit from using any TStrings descendant.

For instance, a TMemoy.LinesTListBox.ItemsTComboBox.Items, etc.
From the outside it looks like they are TStrings, but internally they do not use a TStringList but their own descendant.

A few examples of classes that descend from TStrings:

source\DUnit\Contrib\DUnitWizard\Source\DelphiExperts\Common\XP_OTAEditorUtils.pas:
     TXPEditorStrings = class(TStrings)
source\fmx\FMX.ListBox.pas:
       TListBoxStrings = class(TStrings)
source\fmx\FMX.Memo.pas:
     TMemoLines = class(TStrings)
source\rtl\common\System.Classes.pas:
     TStringList = class(TStrings)
source\vcl\Vcl.ComCtrls.pas:
     TTabStrings = class(TStrings)
     TTreeStrings = class(TStrings)
     TRichEditStrings = class(TStrings)
source\vcl\Vcl.ExtCtrls.pas:
     TPageAccess = class(TStrings)
     THeaderStrings = class(TStrings)
source\vcl\Vcl.Grids.pas:
     TStringGridStrings = class(TStrings)
     TStringSparseList = class(TStrings)
source\vcl\Vcl.Outline.pas:
     TOutlineStrings = class(TStrings)
source\vcl\Vcl.StdCtrls.pas:
     TCustomComboBoxStrings = class(TStrings)
     TMemoStrings = class(TStrings)
     TListBoxStrings = class(TStrings)
source\vcl\Vcl.TabNotBk.pas:
     TTabPageAccess = class(TStrings)

–jeroen

Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development | 1 Comment »

Laptop fan profiling, and debugging them – related to Profiling | CommitStrip

Posted by jpluimers on 2019/07/23

A while back, I posted the “profiling” CommitStrip on[WayBack] Profiling – Jeroen Wiert Pluimers – Google+. Boy how did I not know that within a week, I bumped into a “laptop fan profiling” artefact.

A coworker noticed, that when starting a thread based equivalent of [WayBack] TTimer Class (which cannot be used in services as it depends on the VCL), then sometimes the laptop fans would spin up.

What basically happened was that for certain combinations of Enabled and Interval the Execute would loop burning 100% of one CPU core.

With 3 or more – sometimes 2 – of these threads active on a 4+4 core (4 are hyper-threaded), the processor fan would start to spin like madness.

Finding the solution was somewhat easy too:

  • Process Explorer would show the thread IDs burning the most CPU cycles
  • Delphi shows the Thread IDs in the Thread Status pane (if they are named, the ID is at the end of the name in parenthesis)
  • At around Delphi 2010, you can Freeze or Thaw threads. This allows you to debug only a single thread by freezing all others.

Focussing on one thread, allowed a close inspection of the loop, quickly finding the actual cause and repairing it.

TTimer Thread

A similar and better class is at [WayBack] multithreading – TTimerThread – Threaded timer class – Code Review Stack Exchange, based on [WayBack] timer – Using VCL TTimer in Delphi console application – Stack Overflow.

Read the rest of this entry »

Posted in Conference Topics, Conferences, Debugging, Delphi, Development, Event, Fun, Multi-Threading / Concurrency, Profiling-Performance-Measurement, Software Development | Leave a Comment »

Namespaces in Delphi – Stack Overflow

Posted by jpluimers on 2019/07/23

Blast from the past, but still relevant: [WayBackNamespaces in Delphi – Stack Overflow:

Q

Are there any practical benefits in using long unit file names like MyLib.MyUtils.pas or it is just a kind of unit name prefix?

A

Namespaces, like all identifiers, are meant to organize.

So using them, only benefits if your project gets organized in a better way. This is highly subjective matter (there have been ‘wars’ on even the most simple naming conventions!), so impossible to really answer.

[WayBack] Here is some documentation on how namespaces work in Delphi.

Note that ‘true’ namespaces (where more than one generic DLL can contribute to the same namespace; this is how namespaces function in the .NET world) are not possible in Delphi: you could go the BPL way, but that is not the same as a ‘generic DLL’. This is not a limitation of Delphi itself, but the way that native DLLs in Windows ‘work’.

–jeroen

Posted in Delphi, Development, Software Development | Leave a Comment »

delphi – How to hide the inherited TObject constructor while the class has overloaded ones? – Stack Overflow

Posted by jpluimers on 2019/07/18

Interesting, need to try this one day to see how well this works so the base constructor TObject.Create cannot be called.[WayBack] delphi – How to hide the inherited TObject constructor while the class has overloaded ones? – Stack Overflow

–jeroen

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

Tweaked TStringBuilder in FastCode is now 2x faster than the stock…

Posted by jpluimers on 2019/07/17

Reminder to self as occasionally I concatenate a lot of strings:

[WayBack] After some tweaking TStringBuilder in FastCode is now 2x faster than the stock Builder in SysUtils.  – Johan Bontes – Google+.

Source: FastCode/FastStringBuilder.pas at master · JBontes/FastCode

–jeroen

Posted in Delphi, Development, Software Development | Leave a Comment »

Delphi RTTI Context limitation: not thread safe for method RTTI

Posted by jpluimers on 2019/07/16

In a comment to [WayBack] Update: It was not clear what I was asking so I updated the question. I am trying to call RTTI Invoke from within TTask.Run and I get an AV. I have t… – John Kouraklis – Google+

… you can’t use a TRTTIMethod instance from a TRTTIContext of another thread….

John Kouraklis

+Eric Berger+Panagiotis Drivilas That’s it. Many Thanks

–jeroen

Posted in Delphi, Development, Software Development | 1 Comment »

Design Patterns & Refactoring

Posted by jpluimers on 2019/07/16

Design Patterns and Refactoring articles and guides. Design Patterns video tutorials for newbies. Simple descriptions and full source code examples in Java, C++, C#, PHP and Delphi.

Source: [WayBackDesign Patterns & Refactoring.

And indeed a lot of examples in Delphi too; few sites have that: Delphi site:sourcemaking.com.

–jeroen

Via: [WayBack] I stumbled upon this yesterday, very informative, accessible and also with Delphi examples – among other languages. – Steffen Nyeland – Google+

Posted in .NET, C, C#, C++, Delphi, Design Patterns, Development, Java, Java Platform, PHP, Scripting, Software Development | Leave a Comment »

Thread around DCEF3 leaking memory, but DCEF4 doesn’t taught me to look at madExcept for memory leak checking too

Posted by jpluimers on 2019/07/09

This thread about [WayBack] DCEF3 memory leak in Delphi XE2  – Alberto Paganini – Google+ taught me that madExcept has a much more elaborate memory leak checking than FastMM4: it checks any Windows memory heap allocation, handle leaks, etc, not just the Delphi code induced memory allocations.

Thanks David Heffernan for commenting this part:

The madExcept leak tracking tools are much more comprehensive than those of FastMM because have much greater coverage. FastMM’s leak tracking tools are great, but only track native Delphi allocations. With the madExcept tooling you get all heap allocations (including non-native ones), handle leaks etc.

That is not to belittle the FastMM tooling at all…

Time to again look at [WayBack] madshi.net – madExcept description

–jeroen

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

A COM Object Collection (IEnumVARIANT) – Delphi Tips – CJC Delphi (Cool Delphi Tips)

Posted by jpluimers on 2019/07/04

Summary of [WayBack] A COM Object Collection (IEnumVARIANT) – Delphi Tips – CJC Delphi (Cool Delphi Tips)

Question: How to implements object collection that support Visual Basic’s For Each construct ?

Answer:
In order to implements an object collection your object has to return  IEnumVariant pointer from a special property named _NewEnum.

Via: [WayBack] What interface to I need to implement to allow ForEach in VBA on a COM object written in delphi? – Stack Overflow

–jeroen

Posted in COM/DCOM/COM+, Delphi, Development, Software Development, Windows Development | Leave a Comment »