Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How might I find out the source of long delays on resizing the main form?

I have a D2006 app that contains a page control and various grids, etc on the tabs. When I resize the main form (which ripples through and resizes just about everything on the form that is aligned to something), I experience long delays, like several seconds. The app freezes, the idle handler is not called and running threads appear to suspend also.

I have tries pausing execution in the IDE while this is happening in an attempt to break execution while it is in the troublesome code, but the IDE is not taking messages.

Obviously I'm not expecting anyone to point me at some errant piece of code, but I'm after debugging approaches that might help me. I have extensive execution timing code throughout the app, and the long delays don't show up in any of the data. For example, the execution time of the main form OnResize handler is minimal.

like image 619
rossmcm Avatar asked Mar 02 '11 19:03

rossmcm


People also ask

How do I resize a form in VB net?

By dragging either the right edge, bottom edge, or the corner, you can resize the form. The second way you can resize the form while the designer is open, is through the properties pane.

How do I stop HTML from resizing?

To prevent a text field from being resized, you can use the CSS resize property with its "none" value. After it you can use the height and width properties to define a fixed height and width for your <textarea> element.

How do you make a DIV not resizable?

It is mostly used with textarea and div elements. To disable resizable property of an element use resize to none. It is the default value.


3 Answers

If you want to find out what's actually taking up your time, try a profiler. Sampling Profiler could answer your question pretty easily, especially if you're able to find the beginning and the end of the section of code that's causing trouble and insert OutputDebugString statements around it to narrow down the profiling.

like image 89
Mason Wheeler Avatar answered Sep 24 '22 01:09

Mason Wheeler


OK. Problem solved. I noticed that the problem only occurred when I had command-line switches enabled to log some debug info. The debug info included some HTTP responses that were written to a debug log (a TMemo) on one of the tabs. When the HTTP response included a large block with no CR/LFs the TMemo wrapped it. Whenever I resized the main form, the TMemo resized and the control had to render the text again with the new word wrapping.

To demonstrate:

  • start a new Delphi project
  • drop a TMemo onto the form
  • align it to Client
  • compile and run
  • paste a large amount of text into the TMemo
  • resize the main form

I won't award myself the answer, as I hadn't really provided enough info for anybody else to solve it.

BTW @Mason - would SamplingProfiler have picked this one up - given that the execution is inside the VCL, and not in my code?

like image 34
rossmcm Avatar answered Sep 24 '22 01:09

rossmcm


A brute-force approach that may give results.... Put a debug message to OutputDebugString() from every re-size event, sending the name of the control as the string to be displayed. This may show you which ones are being called "a lot".

You may have a situation where controls are bumping each other, setting off cascading re-size events. Like 3 siblings in the back seat of a compact car, once they start jostling for position, it can take a while for them to "settle down".

Don't make me turn this car arround....

The debug log (viewable in the IDE, or with an external ODS viewer), may show you which ones are causing the most trouble, if they appear multiple times for one "user-initiated re-size event".

like image 42
Chris Thornton Avatar answered Sep 22 '22 01:09

Chris Thornton