25. Notes About Garbage Collection In LotusScript
2013-01-12 14:20
393 查看
Garbage collection is done with three characteristics in Lotusscript.
a) It’s done after the execution of EACH line of code.
b) It reclaims the memory of an object when on local variable references it directly, even when another referenced object links to it.
c) When it reclaims an object, it reclaims all the objects contained by the object. Notes does not allow free-floating objects that exist outside their container, or "owner" object. Documents, for example, must belong to a database. Items must belong to a document,
and ACLEntries must belong to an ACL object.
Point a) ensures the efficient memory usage when a sub involves the iteration of a large number of Notes objects e.g. documents.
Point b) and c) are harmful when they work together.
to be reclaimed. The issue in this case can be fixed by storing the ACL object in a variable.
Another case is as below:
the current database object is not initialized in the caller. The current session and database objects keep alive until the whole program e.g. agent exits. To avoid the failure above, a global variable can be declared to hold the exterior database object.
a) It’s done after the execution of EACH line of code.
b) It reclaims the memory of an object when on local variable references it directly, even when another referenced object links to it.
c) When it reclaims an object, it reclaims all the objects contained by the object. Notes does not allow free-floating objects that exist outside their container, or "owner" object. Documents, for example, must belong to a database. Items must belong to a document,
and ACLEntries must belong to an ACL object.
Point a) ensures the efficient memory usage when a sub involves the iteration of a large number of Notes objects e.g. documents.
set view = db.GetView("$all") set doc = view.GetFirstDocument() while not (doc is nothing) ' do something... set doc = view.GetNextDocument(doc) wend
Point b) and c) are harmful when they work together.
dim s as new NotesSession dim entry as NotesEntry set entry = s.CurrentDatabase.ACL.GetFirstEntryThe entry object will be reclaimed right after the assignment statement is executed as the ACL object is not stored in any variable and thus destructed, which causes the child object ACLEntry
to be reclaimed. The issue in this case can be fixed by storing the ACL object in a variable.
Another case is as below:
Sub Initialize Dim s As New NotesSession Dim view As NotesView Set view=TestObj() Print view.Name End Sub Function TestObj As NotesView Dim s As New NotesSession Dim db As NotesDatabase Set db=s.Getdatabase(s.Currentdatabase.Server, "log.nsf") Set TestObj=db.Getview("UsageByUser") End functionThe View object returned by the function TestObj is reclaimed before it can be used by the caller because the parent database log.nsf is reclaimed after the function ends. If the view is from the current database, it will keep alive, even if
the current database object is not initialized in the caller. The current session and database objects keep alive until the whole program e.g. agent exits. To avoid the failure above, a global variable can be declared to hold the exterior database object.
Sub Initialize Dim s As New NotesSession ‘the following two lines are optional Dim db As NotesDatabase Set db=s.Currentdatabase Dim view As NotesView Set view=TestObj() Print view.Name End Sub Function TestObj As NotesView Dim s As New NotesSession Set TestObj=s.Currentdatabase.Getview("All") End function
相关文章推荐
- Notes: Garbage Collection in Java(Java的自动垃圾回收机制)
- Notes: Garbage Collection in Java(Java的自动垃圾回收机制)
- Garbage Collection in Actionscript3.0
- Notes: Garbage Collection in Java(Java的自动垃圾回收机制)
- Notes: Garbage Collection in Java(Java的自动垃圾回收机制)
- Notes: Garbage Collection in Java(Java的自动垃圾回收机制)
- Notes: Garbage Collection in Java(Java的自动垃圾回收机制)
- Notes: Garbage Collection in Java(Java的自动垃圾回收机制)
- 项目经验:在调用LotusScript Arrayunique 函数时会导致Domino 服务器或Notes 客户端宕机
- notes about crosstool,uboot,mysql and some tools in linux(ubuntu)
- PPT - Garbage Collection in .Net (内存管理)
- .net 垃圾回收学习 The Truth About Garbage Collection [Java][翻译]
- Garbage Collection in the Java HotSpot Virtual Machine
- Garbage Collection in .NET - How it really works
- PPT - Garbage Collection in .Net (内存管理)
- A few notes about the CommDb (use in Symbian OS)
- Use Custom Classes in Your LotusScript Code - Part
- Understanding Garbage Collection in the .NET Framework.
- A Glance At Garbage Collection In Object-Oriented Languages
- Limits on numeric data representation in LotusScript