Domino Code Fragment

Code Name*
Memory leak checking for LotusScript
Date*
10/20/1999
Source (or email address if you prefer)*
john@dalsgaard-data.dk
IP address:.3.145.152.242
Description*
Code that you can place at beginning and end of an agent to see if it is leaking memory
Type*
LotusScript
Categories*
Design Configuration, Diagnostics/Analysis/Debugging, (Misc)
Implementation:
Modify constants
Required Client:
Server:
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:

 Company:  Dalsgaard Data

 Contact:  John Dalsgaard

 URL:  http://www.dalsgaard-data.dk


Description
Most of you may have discovered memory leaks when your Notes
client is running a large job or just running an application on
the Domino server.

I have seen it in various places - and the sources to the problems
may be almost impossible to identify in your code.

I have come across the following undocumented (as far as I know)
features that can assist you in finding the the malicious code.



 Code  The basic trick is to know the name of a function call to some
      internal registers that will return the information needed:

       LotusScript Memory Allocated: Lsi_info(50)
      LotusScript Memory Allocated from OS: Lsi_info(51)
      LotusScript Blocks Used: Lsi_info(52)

       Now if you want to use this code in a foreground agent it could
      look like this:

       Sub Initialize
      Msgbox(" Total LotusScript Memory Allocated: " + (Lsi_info(50)))
      Msgbox(" Total LotusScript Memory Allocated from OS: " +
      (Lsi_info(51)))
      Msgbox(" Total LotusScript Blocks Used: " + (Lsi_info(52)))
      End Sub

       To find out if there is a leak you will have to run the code
      BEFORE and AFTER the code that you want to investigate.

       If you want to use the code in a background agent you would have
      to print to the LOG.NSF by using code that looks like this:

       Sub Initialize
      Print "Memory Allocated: " + Str$(Lsi_info(50)) + Chr$(10) + Chr
      $(13)
      Print "Total LotusScript Memory Allocated from OS: " + Str
      $(Lsi_info(51)) + Chr$(10) + Chr$(13)
      Print "Total LotusScript Blocks Used: " + Str$(Lsi_info(52)) + Chr
      $(10) + Chr$(13)
      End Sub

       Be careful if you write the information to a document in a
      database (say your own log facility) since this does also consume
      some memory and thus the BEFORE and AFTER measurements are NOT
      going to be equal.