Jump to content
Bogdan Polak

DUnitX and testing MemoryLeaks

Recommended Posts

Hi!

I found nice piece of code from VSoft: https://github.com/VSoftTechnologies/DUnitX/blob/master/Tests/DUnitX.Tests.MemoryLeaks.pas

but I can't find any memory leak report after running this test. Do you know who to configure DUnitX project to report memory leaks? Is it possible to see the report of all tests with Memory Leaks in TestInsight? Maybe any link with the documentation about that?

 

I know Honza Rameš - delphi-leakcheck, but this project looks like abandoned (2+ years since last commit) and I'm looking for the alternative.

 

Thanks,

Bogdan

Share this post


Link to post

I suspect you have to use FastMM as well, check DUnitX.MemoryLeakMonitor.FastMM4.pas.

Anyway the devs seem not using test project at all, it is even not compilable in current state.

Btw, FastMM has its own pretty useful leak report

Share this post


Link to post

Thanks a lot for the answer, but I need something more integrated into unit tests suite then just FastMM reporting:

1) There should be verification of memory leaks comparing two points: before setup and teardown of each test, and if there are any leaks then unit tests engine is reporting this test as failed test.

2) You are able to disable memory leaking checks for some test methods (custom attributes)

 

It will be of topic point, but just can't stop myself from not commenting. In my opinion this is a bad perception that "devs seem not using test project at all". I'm strongly disagree with that and knows lots of teams which are using unit test suites based on Unit or DUnitX framework. My pespective is diffrent: more and more Delphi devs are starting to adopt unit tests approach - usualy not for the whole projects, which is much more challenging and requires really strong Delphi architect person on board.

Share this post


Link to post

Memory leak reporting in delphi unit tests are difficult to do accurately, as the test framework is using the same memory manager as the tests.

 

Not sure who this is aimed at "Anyway the devs seem not using test project at all, it is even not compilable in current state." but I can assure you as a dev on DUnitX and many other projects I use unit testing every day. There is some debris in the dunix repo, mostly in the fmx area due to the lack of compatibility between fmx versions (and I don't use or work on fmx stuff).  It's not easy to keep everything in a compiling state for a ton of different delphi versions, especially when I don't have every version installed.  

 

Share this post


Link to post
8 hours ago, Bogdan Polak said:

Thanks a lot for the answer, but I need something more integrated into unit tests suite then just FastMM reporting:

1) There should be verification of memory leaks comparing two points: before setup and teardown of each test, and if there are any leaks then unit tests engine is reporting this test as failed test.

2) You are able to disable memory leaking checks for some test methods (custom attributes) 

FastMM reporting was only one of the options, I also said that DUnitX's mem leak feature uses FastMM facilities.

 

8 hours ago, Bogdan Polak said:

It will be of topic point, but just can't stop myself from not commenting. In my opinion this is a bad perception that "devs seem not using test project at all"

 

7 hours ago, Vincent Parrett said:

Not sure who this is aimed at "Anyway the devs seem not using test project at all, it is even not compilable in current state." but I can assure you as a dev on DUnitX and many other projects I use unit testing every day

Probably I expressed my point a bit unclear. By "Test project" I referred to DUnitX's self-test project. It has some minor glitches that make it uncompilable (in uses clause). Probably these are leftovers from an old times. Surely there was no offense intention, the project is great (and, what's very important, alive).

Edited by Fr0sT.Brutal

Share this post


Link to post

Use LeakCheck - there is even a blog post how to. Not having done anything on something that just works does not mean abandoned.

If something does not work, let him know.

 

FastMM is good to report memory leaks on an entire application run but not suited for unit tests memleak reporting - that is why LeakCheck was written plus having something that works cross platform.

Edited by Stefan Glienke
  • Like 2

Share this post


Link to post
4 hours ago, Fr0sT.Brutal said:

Probably I expressed my point a bit unclear. By "Test project" I referred to DUnitX's self-test project. It has some minor glitches that make it uncompilable (in uses clause). Probably these are leftovers from an old times. Surely there was no offense intention, the project is great (and, what's very important, alive).

The GUI projects have issues, I don't use them and haven't worked on them.. not sure when they broke but will try at least the fix the VCL one. FWIW, the console tests project and the console examples project both compile and run fine. You really don't need a gui to run unit tests, except when developing, and for that I use TestInsight. 

  • Like 1

Share this post


Link to post

@Vincent Parrett lol now when you mentioned a console project I noticed the bunch of DUnitXTest_*.dpr files :D. I've really overlooked them thinking it's just packages or similar. Is it really necessary having a specific project file for each compiler version?

Share this post


Link to post
10 hours ago, Fr0sT.Brutal said:

Is it really necessary having a specific project file for each compiler version?

I think it was done because every contributor was editing in a different version of delphi, which then changed the dproj file and broke it for older versions. 

Share this post


Link to post
On 11/14/2019 at 9:43 AM, Stefan Glienke said:

Use LeakCheck - there is even a blog post how to. Not having done anything on something that just works does not mean abandoned.

If something does not work, let him know.

Cool ... Thanks Stefan for your feedback. If you recomend Delphi-LeakCheck that it have to be helpful. 🙂 I'm going to use it. Next week!

 

Personally I have never opportunity to meet Honza Rameš live and for sure he has an eye on this project, but once I had bad experience with untouched open source project and now I'm more careful.

 

I saw this Medium article previouslly (uncle Google is the best), which is really great tutorial by Andrei 👏

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×