Solved

Delphi 7 debugger hangs briefly on application exit

Posted on 2007-12-05
7
1,191 Views
Last Modified: 2013-11-23
Experts,

I use Delphi 7. On occasion, when I am running an application in the debugger and I exit the application normally, Delphi seems to get hung, and hangs the rest of my computer desktop as well. This always remedies itself after some period of time. Sometimes it takes a few seconds, sometimes as much as a minute, and sometimes not at all  all within the same application. It only happens when debugging, the applications all run fine outside of the debugger. This only happens when I terminate the application normally  if I do a Program Reset I return to the debugger with no delay.

I have never been able to tell what is going on when this happens. Ive tried watching task manger when it occurs but even the task manager is not updating its screen when this goes on. I suspect its bad behavior on the part of some component that I am using because it does not happen with simple programs, only my more involved projects.

Has anyone else experienced this? Any Ideas?
 
Thanks,

Steve
0
Comment
Question by:SteveBay
  • 4
  • 3
7 Comments
 
LVL 28

Expert Comment

by:2266180
ID: 20414630
are you using memcheck/fastmm with some debugging configured/etc? these kind of componetns will usually compute some information related to memory usage, but you should get some a message saying so because usually there is always something that is "left unreleased".

other then that, I am afraid you will have to provide us with the list of 3rd party components you are using in your project.
0
 
LVL 14

Author Comment

by:SteveBay
ID: 20415181
I use AQTime for profiling and memory leak detection. It is not integrated with the debug environment.

The 3rd party component list is long and varied. So I looked for the lightest application I could find that has exhibited this behavior.

This particular application is a DLL that reads data from an XML and updates Data in a MSSQL database. Its 3rd party components are limited to the following:

Raize Components (Ive use them in just about every thing for many years. I highly doubt that these are the problem).

There are also a number of CodeSite calls (also from Raize).
This could be a suspect because it sends windows messages and could be sending millions upon exit. I have made efforts to disable all CodeSite calls and have still seen the behavior. This also would not explain why it only happens in the debugger as CodeSite works the same with or without the debugger. And once again, I've been using it for many years in lots of stuff and this issue has only come up recently, the last 6-8 months or so. I've also search Raize news groups for similar reports and found none. Still, I am not ready to completely rule this one out.

TLbBlowFish  - formerly from TurboPower now open source from Source Forge;

NativeXML - from www.simdesign.nl/xml.html. Theres not enough going on in this component to warrant unexpected behavior.


0
 
LVL 28

Accepted Solution

by:
2266180 earned 500 total points
ID: 20415382
>> It is not integrated with the debug environment.
it doesn't have to be. these components usually detect if the debugger is running or not.

in any case, first place to look at, are the finalization sections of the units.

if nothing comes up after a quick view, I would do somethign like the following to detect where the "freeze" occures:
- use a logging system
- log a line right after application.run in the dpr file
- log a line in the destructor of the main form as well
- create 2 units, named blabla1 and blabla2 (name it to whatever you like), and in the finalization section add a log line in both
- logging usefull information is a must (like: now executing finalization section of unit blabla1, or destructor of main form, etc)
- the logger must be able to also log the time of the call so that you know when the message was logged

now, with this prepared (it should really only take a few minutes to setup everything, provided you have a logging system with the minimum characteristics mentioned above).

now, step 2:
- place the unit blabla1 as the first unit in the dpr, BUT, without messing up whatever other units MUST be first (like madexcept, fastmm, etc. probably your AQTime also has a unit there first). this blabla1 will come the first after all the others
- place the unit blabla2, as the last unit in the dpr.

and now, I think you know what comes :) trial and "error" of the "divide et impera".
looking in the logs, you will notice where the "freeze" is happening. if you're lucky, you find it fast from the first call as belonging to either the first units from the dpr, or to some code after the main form destruction and project finalization.
if not, then you will notice the freeze to be between blabla1 and blabla2. so, move blabla1 down some units (preferably half). is it still between blabal1 and blabla2? if yes, again move it down, if not, move it back to first and move blabla2 in it's place. repeat.
eventually, you will end up with who is making the freeze.

it's ugly, but I don't know of any automated tool to trace the execution time of calls.
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 14

Author Comment

by:SteveBay
ID: 20415651
Good stuff ciuly...:)

CodeSite is my logging util. I put a call in the dpr right after the Run. and I put one in the Mainform destructor. Both of those were called before the hang occured.

BTW I ran the program 5 times and it only causes a hang once about 30 seconds.

I don't know what you are refering to by "finalization section of unit". Is that the form destructor?
0
 
LVL 28

Assisted Solution

by:2266180
2266180 earned 500 total points
ID: 20415918
no. in a unit you have a several sections:

interface
implementation
initialization
finalization

the most used are the first 2. but there are cases when the otehr 2 are used as well. so some of you runits will have them some not.

see below example of blabal1.pas
unit blabla1;
 
interface
 
implementation
 
initialization
// nothing
 
finalization
  log('blabla1');
 
end.

Open in new window

0
 
LVL 14

Author Comment

by:SteveBay
ID: 20416040
Thanks,
You know, sometimes all a guy has to do is hit F1 and type a word (in this case "finalization") and a whole world of knowledge come pouring out:)

So I've done all of that and I will watch for the results.

In the mean time, just for grins, I when into Project->Options->Compiler and disabled everything in the Debugging section. The hang went away. (keep in mind it was only happing about 1 in 5 runs to begin with). I re-enabled every thing in the Debugging section, and the hang stayed away. I have not been able to reproduce the hang at all now. after several dozen runs - no hang.
Hmmm.

Your help has been quite valuable.  Thank You

0
 
LVL 28

Expert Comment

by:2266180
ID: 20416153
now there is a weird thing to keep in mind :)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi TcxGrid group footer summary 3 323
control image tags in a string ? 12 142
I want to use librsync in my Delphi backup application. 3 60
Wincontrol not (correctly) drawn 15 42
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question