You may have discovered memory leaks when your Notes client is running a large job or just running an application on your Domino server. The leaks can occur in various places — and the source of the problems may be almost impossible to identify in your code. Here are some undocumented techniques that can help you find code that might be causing memory leaks.
The trick is to know the name of a function call to some internal registers that will return the amount of memory in use. Here are the types of information returned and the function names:
LotusScript Memory Allocated: Lsi_info(50)
LotusScript Memory Allocated from OS: Lsi_info(51)
LotusScript Blocks Used: Lsi_info(52)
Here's a LotusScript code fragment that shows how to use these functions in a foreground agent:
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 determine whether a leak exists, you must run this code BEFORE and AFTER the portion of code you want to investigate. If you want to use the above code in a background agent, you must print the results to the LOG.NSF using code like this:
Sub Initialize
Print "Memory Allocated: " & CStr(Lsi_info(50))
Print "Total LotusScript Memory Allocated from OS: " & CStr(Lsi_info(51))
Print "Total LotusScript Blocks Used: " & CStr(Lsi_info(52))
End Sub
If you write the information to a document in a database (for example, your own log facility), be careful because this procedure also consumes some memory, and thus, the BEFORE and AFTER measurements will NOT be equal. Also, because these techniques are undocumented, use them at your own risk, and make sure you have good backups before implementing them.
1 comment :
great tip. Thanks!
Post a Comment