Title: PowerPointpresentatie
1PTW-043 Dynamic Debugging In OpenEdge
Peter van Dam pvd_at_netsetup.nl
2Agenda
- Creating memory leaks in the 4GL
- The new Debugger
- Checking memory leaks in 4GL
- Enhanced logging in OE10
- Dynamic Query Tester
- Dynamic Temp-table Viewer
- Dynamic AppServer debugging
3Agenda
- Creating memory leaks in the 4GL
- The new Debugger
- Checking memory leaks in 4GL
- Enhanced logging in OE10
- Dynamic Query Tester
- Dynamic Temp-table Viewer
- Dynamic AppServer debugging
4Dynamic Programming
- Dynamic Windows, Frames Widgets
- Dynamic Browses
- Dynamic Buffers Queries
- Dynamic Temp-Tables
- Objects, Handles, Methods Attributes
- AppServer
- WebClient
5Memory leaks
- Show up after a long time
- Can be extremely difficult to track down (until
now)
Bites you at deployment!
6Memory leaks
- Dynamic objects arescoped to the session
- You are responsible fordeleting objects when you
are done with themDELETE OBJECT
hBuffer.hBuffer ?. - Use VALID-HANDLE in your code
7Memory leak example
- / countcust.p /
- DEF VAR hQuery AS HANDLE NO-UNDO.
- DEF VAR hBuffer AS HANDLE NO-UNDO.
- DEF VAR iCount AS INTEGER NO-UNDO.
- CREATE BUFFER hBuffer FOR TABLE "customer".
- CREATE QUERY hQuery.
- hQuerySET-BUFFERS(hBuffer).
- hQueryQUERY-PREPARE("FOR EACH customer
NO-LOCK"). - hQueryQUERY-OPEN().
- hQueryGET-FIRST().
- DO WHILE hBufferAVAILABLE
- iCount iCount 1.
- hQueryGET-NEXT().
- END.
- MESSAGE iCount "customers found" VIEW-AS
ALERT-BOX.
8Memory leak example
- / countcust.p /
- DEF VAR hQuery AS HANDLE NO-UNDO.
- DEF VAR hBuffer AS HANDLE NO-UNDO.
- DEF VAR iCount AS INTEGER NO-UNDO.
- CREATE BUFFER hBuffer FOR TABLE "customer".
- CREATE QUERY hQuery.
- hQuerySET-BUFFERS(hBuffer).
- hQueryQUERY-PREPARE("FOR EACH customer
NO-LOCK"). - hQueryQUERY-OPEN().
- hQueryGET-FIRST().
- DO WHILE hBufferAVAILABLE
- iCount iCount 1.
- hQueryGET-NEXT().
- END.
- MESSAGE iCount "customers found" VIEW-AS
ALERT-BOX.
9Agenda
- Creating memory leaks in the 4GL
- The new Debugger
- Checking for memory leaks in 4GL
- Enhanced logging in OE10
- Dynamic Query Tester
- Dynamic Temp-table Viewer
- Dynamic AppServer debugging
10The new Debugger
- A brand new Debugger was introduced in OE 10
(actually 9.1D05) - You must enable the Debugger in OE10
11Enabling the Debugger in OE10
12The Open Edge 10 Debugger
- The new Debugger now also allows you to trace
memory leaks - Use the debugalert startup parameter to invoke
it from any message box (demo) - Or start from the 4GL (demo)
- Or attach to a process (demo)
- Trace a memory leak (demo)
- Inspect dynamic properties (demo)
13Agenda
- Creating memory leaks in the 4GL
- The new Debugger
- Checking for memory leaks in 4GL
- Enhanced logging in OE10
- Dynamic Query Tester
- Dynamic Temp-table Viewer
- Dynamic AppServer debugging
14Checking memory leaks in 4GL
- New in OE10 SESSIONFIRST-QUERYhQuery
SESSIONFIRST-QUERY.DO WHILE VALID-HANDLE(hQuery)
ASSIGN iQueries iQueries 1. hQuery
hQueryNEXT-SIBLING.END. - SESSIONFIRST-BUFFER already in 9.1B
- Demo countcustmemcheck1.p
15Getting more info from the 4GL
- Remember if you have the handle of an object,
you can query its attributes - For example, for a BUFFER you can find the table
name - For a QUERY you can find the PREPARE-STRING
- Tip use the NAME and PRIVATE-DATA attributes to
identify dynamic objects - Demo countcustmemcheck2.p
16What can you check in the 4GL
- Dynamic BUFFERS and TEMP-TABLES
- Dynamic QUERIES
- Dynamic DATASETS and DATA-SOURCES
- SERVERS and SOCKETS
- PERSISTENT PROCEDURES
- Non-modal WINDOWS
- Demo countcustmemcheck3.p
17What is still missing in the 4GL
- SESSIONMEMORY-SIZE
- SESSIONFIRST-WIDGET-POOL
- WIDGET-POOLFIRST-OBJECT
Just as well, because all the fun would be gone!
18Agenda
- Creating memory leaks in the 4GL
- The new Debugger
- Checking for memory leaks in 4GL
- Enhanced logging in OE10
- Dynamic Query Tester
- Dynamic Temp-table Viewer
- Dynamic AppServer debugging
19Enhanced logging in OE 10
- In Open Edge 10 the LOG-MANAGER system handle was
introduced - You can use it dynamically to log resources and
events in detail - The most important attributes for dynamic
debugging are LOGFILE-NAME and LOG-ENTRY-TYPES
20LOG-MANAGERLOGFILE-NAME
- You can only set LOG-MANAGERLOGFILE-NAME once
per session - So you cannot change log files during the session
- Regrettably it is also not possible to clear the
log file during the session
21LOG-MANAGERLOG-ENTRY-TYPES
- There are many log entry types
- You can set and unset them during the session
- Each log entry type can have different logging
levels - I created the Dynamic Debugging Logging
Settings window to add to your PROTools palette
22Dynamically SettingLog Entry Types and Logging
Levels
23Using enhanced logging
- Demo Switch on the Dynamic Database Objects
logging type, set the level to 3 or 4 and run
countcust.p again - The log file will show that a dynamic BUFFER and
dynamic QUERY object are created in an unnamed
widget pool but not deleted
24Other useful Log Entry Types
- 4GLTrace turns on logging for all RUN, FUNCTION,
PUBLISH and SUBSCRIBE statements. - Dynamic UI Objects tells you where dynamic
widgets are created and deleted in your
application. Example Track down error 4025
(Unable to realize widget).
25Query logging
- Query Information adds very detailed information
on dynamic queries. Example track down all
WHOLE-INDEX queries in your application. - You can also log information from individual
queries by settinghQueryBASIC-LOGGING
TRUE.Demo countcust4.p
26Event logging
- Printable Character Events logs all events
concerning printable characters. - Non-printable UI Events logs events concerning
non-printable characters and WM GUI events. - Other Events logs COM, Async and Sockets events
27Agenda
- Creating memory leaks in the 4GL
- The new Debugger
- Checking for memory leaks in 4GL
- Enhanced logging in OE10
- Dynamic Query Tester
- Dynamic Temp-table Viewer
- Dynamic AppServer debugging
28Analyzing Dynamic Queries
- You can gather information on your dynamic
queries using the Query Information Log Entry
Type - During development it would be nice if you could
analyze your dynamic queries interactively - Marius Fiere wrote a Query Tester for this purpose
29Dynamic Query Tester
- Publish your QUERY-PREPARE strings
forinterception by the Query TesterPUBLISH
QUERY (hQueryPREPARE-STRING). - Press the Full Test button for live analysis
- Demo run countcust3.p
30Dynamic Query Tester results
- The Query Tester makes clever use of Dynamic
Queries and VSTs (IMHO better information than
DynObjects.DB Logging) - The analysis shows that this query cannot use an
index - The Query Tester traps this problem although the
performance is fine in the development environment
31Agenda
- Creating memory leaks in the 4GL
- The new Debugger
- Checking for memory leaks in 4GL
- Enhanced logging in OE10
- Dynamic Query Tester
- Dynamic Temp-table Viewer
- Dynamic AppServer debugging
32Dynamic Temp-table memory leaks
- Dynamic temp-tables aremost likely to cause
memory leaks - OUTPUT TABLE-HANDLES are created in the SESSION
WIDGET-POOL (whether you like it or not) - You need to delete those explicitly
332 dynamic temp-table memory leaks
OUTPUT TABLE-HANDLE
CREATE TEMP-TABLE
DB
tt-leak1.p
tt-leak2.p
- tt-leak2.p contains a CREATE TEMP-TABLE statement
that creates the TEMP-TABLE in the current
WIDGET-POOL - The temp-table received by tt-leak1.p is created
in the SESSION WIDGET-POOL
34LOG-MANAGER information
- Demo Switch on Dynamic Database Objects logging
and run tt-leak1.p - The log shows that the following objects are
created but not deleted
35Dynamic Temp-Table Viewer
- Lets you examine dynamic temp-tables in memory
- Download tool from www.v9stuff.com
- It shows only one memory leak
- Can you explain why?
- Can you find out how?
36Agenda
- Creating memory leaks in the 4GL
- The new Debugger
- Checking for memory leaks in 4GL
- Enhanced logging in OE10
- Dynamic Query Tester
- Dynamic Temp-table Viewer
- Dynamic AppServer debugging
37AppServer Debugging
- Enhanced Debugging is also available in AppServer
environments - Logging information is written to the normal log
files - When you hunt for memory leaks, you sometimes
want to inspect the memory of these remote
Progress sessions - You can do this by splitting the memory checker
in a client part and a server part
38Checking AppServer memory
Getappsmeminfo1.p
Getappsmeminfo2.p
DB
(Web)Client
AppServer
- The AppServer program takes a snapshot of
AppServer memory usage and returns the result to
the client for further processing
39Publishing debug information
- Instead of adding and removing debug messages in
your code, you can PUBLISH the information - At any point in time you candecide to subscribe
to it andprocess the information - This could mean display on aclient, write to a
log file on theserver, analyze etc. - I use standard debug levels Demo
40The new Debugger
- In OpenEdge 10.0B you can now also attach the
debugger to an AppServer process anywhere on your
network!
41Conclusion
- Open Edge 10 provides you with a spectrum of
tools that can help you troubleshoot dynamic
programs - More capabilities have been added to the 4GL for
this but there are always wishes left - Start exploring the new Debugger
- Using handles, VSTs and pub/sub you can write
your own tools
42More information
- Progress documentation
- OpenEdgeTM Development Debugging and
Troubleshooting - OpenEdgeTM Development Progress 4GL Handbook
(John Sadds latest book) - All example programs and tools used in this
presentation are included on your conference CD - www.v9stuff.com
- Progressions magazine (www.wss.com)
- Progress Email Group (www.peg.com)
43Question time