The Wiert Corner – irregular stream of Wiert stuff

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

  • My work

  • My badges

  • Twitter Updates

  • My Flickr Stream

    MPS_9791

    MPS_9795

    MPS_9793

    More Photos
  • Pages

  • All categories

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

    Join 430 other followers

Archive for the ‘FastMM’ Category

Delphi – Using FastMM4 part 3: wrong persistent field type (TSmallIntField or TWordField) when getting IsNull results in memory corruption

Posted by jpluimers on 2009/08/17

This is the third post in a series around using FastMM4.
The start of the series contains a listing of other posts as well and will be updated when new posts become available.

This particular case is about detecting memory overwrites like FastMM has detected an error during a FreeMem operation. The block footer has been corrupted..
Some of them are extremely hard to pin down, especially because there are usually two cases:

  1. Allocated memory that is too small to hold the data structure
  2. Free memory that still has a reference to it, which is used after it was freed

This post is on the first case.
A future post will handle an example of the last case.
Read the rest of this entry »

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

Delphi – Using FastMM4 part 2: TDataModule descendants exposing interfaces, or the introduction of a TInterfacedDataModule

Posted by jpluimers on 2009/08/10

This is the second post of a series of posts around using FastMM4.
The start of the series contains a listing of other posts as well and will be updated when new posts become available.

One of the larger projects I’ve becoming involved in, uses a pattern that uses TDataModule descendants exposing interfaces.
Interfaces in Delphi are nice: if used properly, you have reference counting that will automatically free the underlying objects if there are no references left to them.

When you do not do interfaces in Delphi properly, you are bound to have a lot of memory leaks, and this is one of the cases where we did.
The client choose to do testing and QA very late in the product cycle, and we choose to use FastMM to do memory debugging.
Lo and behold: a truckload of memory leaks appeared all having to do with those datamodules.

As a side node:
Another thing we bumped into at an earlier stage was lifetime management in general: (both interface and object) references were kept to objects long after they were disposed.
That caused a lot of EAccessViolation
pain.
It is best not to mix the “interface reference” pattern with the “owned component” pattern: you usually end up with many more EAccessViolation exceptions.

This article is about finding the memory leaks caused by the way the interfaces were exposed from the TDataModule descendants, and a solution for preventing them by introducing the concept of TInterfacedDataModule.
Read the rest of this entry »

Posted in Database Development, Debugging, Delphi, Development, FastMM, Software Development | 8 Comments »

Delphi – FastMM: Using FastMM4 for debugging your memory allocations – part 1: Introduction

Posted by jpluimers on 2009/07/29

I’m using FastMM in our projects when debugging memory allocations.

It is a great tool, but documentation is sparse.
Hence this post: point to some introductory articles and add some of my own experiences.

Later on, I will show some more advanced use.
These posts are already available in this series:

  1. Delphi – FastMM: Using FastMM4 for debugging your memory allocations – part 1: Introduction
  2. Delphi – Using FastMM4 part 2: TDataModule descendants exposing interfaces, or the introduction of a TInterfacedDataModule

So now lets get on with the introduction:
Read the rest of this entry »

Posted in Delphi, Development, FastMM | 17 Comments »

Delphi – backwards compatibility: using {%File to add non-Delphi files to your project in the .dpr

Posted by jpluimers on 2009/07/27

When you add a non-Delphi file to your project, the current (Galileo based) IDE’s add them only to your .dproj file.
But older Delphi’s used to add them to the .dpr file using the (undocumented) {%File pseudo-directive.

When including the file ..\src\Defines.inc, you need this pseudo-directive: {%File ‘..\src\Defines.inc’}

The .dpr import wizard knows about it: if you have a lonely .dpr file using the {%File pseudo-directive, it will be correctly reflected in the .dproj file.
Read the rest of this entry »

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

 
Follow

Get every new post delivered to your Inbox.

Join 430 other followers