recycle (NotesBase - JavaScript)

Unconditionally destroys an object and returns its memory to the system.

Defined in

NotesBase

Syntax

recycle() : void

recycle(vector:java.util.Vector) : void

Parameter Description
vector The Domino® objects to be recycled. The second method effectively batches recycle operations.

Usage

These methods are inherited by all Domino® classes except NotesError, NotesException, and NotesFactory.

These methods have no knowlege of the heavyweight backend Domino® Objects, only the lightweight Java objects representing them. Garbage collection has no effect on Domino® Objects unless you first explicitly recycle them.

If you appear to have memory problems, try recycle but adhere to the following guidelines:
  • Recycle an object only if it is no longer needed.
  • Do not recycle a global object such as session, database, or view, nor a view or document object to a data source.
  • Recycling a parent recycles all the children.
  • Loops enumerating documents or items are good candidates for recycling.
If you create more than one object to represent the same Domino® element, recycling one recycles all. For example:
var v1 = db.getView("All");
var v2 = db.getView("All");
v1.recycle(); // also recycles v2

Results are undefined if you attempt to use a recycled object. No error is guaranteed.

Language cross-reference

recycle in Java classes
This example recycles a NotesView object after it is used:
var v = database.getView("All");
try {
	if (v == null) return "No \"All\" view."
	return "Number of columns in \"All\" view = " + v.getColumnCount()
} finally {
	v.recycle()
}