views:

726

answers:

4

Does the same technique which FastMM4 for Delphi provides to report memory leaks to a detailed file work if the application runs as service? Of course the best practice would be to write unit tests and a simple standalone application first, and find the leaks there, outside the service environment.

Edit: and there is http://blog.delphi-jedi.net/2008/05/07/debugging-services-an-easy-way/

+1  A: 

Yes, provided the account used to running the service has enough rights to write the log file.

Lars Truijens
+3  A: 

As Lars Truijens notes, writing to a log file requires file system privileges. The default Local System account (i.e. when you do not set an account explicitly or logon in your code) has full access to the local file system but has no default network access.

FWIW - I typically develop my services as regular Windows apps until the main part of the logic is up and running and stable. Using a library like SvCom allows you to run your services as a regular desktop application or as a service without any code changes.

David Taylor
Likewise - I have two versions: the service, and a standalone app that has a form which starts the service module and makes it run as normal. Ideal for doing things like leak checking etc.
mj2008
Agreed, I will always maintain a console or GUI version of the application used primarily for testing and troubleshooting.
Ryan VanIderstine
A: 

I am having the same challenge at the moment. I tried this, but it does not work, at least so far for me. There are sufficient rights for the account, since the service can write his own proprietary logfile. I have switched on FullDebugMode and added the dll, I have switched on LogMemoryLeakDetailToFile, both via the IDE options. In the code I see that the right areas are seen by the compiler, when I provoke an error for example, the compiler reports it. Also I cannot debug the FastMM code. If I put a breakpoint it is ignored. I have searched all my local hard disks where that report might be gone to, it is not to be found. I start and stop the service from 'Administration-Services', all goes well, it starts up, but no report. If I do the same with a normal executable, all goes well. I am using FastMM478, and Delphi2007.

Marc

A: 

Ok I found out another reason why sometimes you cannot see any output, logfile or messagebox......

If you do not make any error, it does not create any output.

So to test if FASTMM478 works deliberately make an error in your program like:

//Create and to NOT destroy testToMakeError := TStringList.Create; for I := 0 to 100 do testToMakeError.Add('krijgtochhelemaaldeklere');

I just presumed I would have made some error somewhere and spend a day trying to find out why the program did not gave me any feedback.

Marc