Article
· Jan 4 1m read

What to do when a large amount of memory is used while processing relationships

InterSystems FAQ rubric

If a relationship is set and there is a large number of n in a 1:n ratio, a large amount of memory may be consumed due to sequential processing of the relationship.

After referencing a many-sided object in a program and internally swizzling it, simply releasing the variable containing the OREF (deleting it, setting another value, etc.) will not free the many-sided object and the relationship object. This is the cause.

To free them completely from memory, you need to explicitly free them by freeing the OREF variable and executing the Relationship object's %UnSwizzleAt<%Library.RelationshipObject> method.

- Example of use -

 Do {
    Set employee = company.Employees.GetNext(.key)
    If (employee '= "") {
        Write employee.Name,!
        // remove employee from memory
        Do company.Employees.%UnSwizzleAt(key)
    }
 } While (key '= ""

There is no particular problem if there are only a few many-side objects, but if there are a large number of linked objects and they are accessed continuously using a loop statement, a large number of objects will continue to be expanded in memory. This is one of the causes of memory pressure.

To avoid such situations, it is necessary to include explicit release processing.

Discussion (0)0
Log in or sign up to continue