I'm looking into memory management in the ECMAScript wrappers at the moment.
Usually, nothing has to be cleaned up as the garbage collector takes care of cleaning up object instances of strings, numbers, RVector, RLine, RLineData, etc.
However, there are some types of objects which have to be cleaned up manually if they are created in ECMAScript:
- RMemoryStorage
- RSpatialIndexNavel
- RDocument
- RDocumentInterface
Documents can for example be created like this:
Code: Select all
var st = new RMemoryStorage();
var si = new RSpatialIndexNavel();
var d = new RDocument(st, si);
var di = new RDocumentInterface(d);
The memory storage and spatial index are owned by the document. The document is owned by the document interface, so cleaning up the document interface is enough in this case:
Scenes and views attached to the document interface are also cleaned up automatically.
If there is no document interface, you need to destroy the document directly. Similarly, if there is no document (unlikely), you need to destroy the storage and spatial index.
There are also appear to be some Qt classes that need to be cleaned up manually if created in ECMAScript:
- QPrinter
- QPainter
- QXmlResultItems
- QXmlStreamWriter
- possibly more..?
Some of the ECMAScripts from QCAD self need to be fixed to take these things into account, so if you still experience leaks, that might be the reason.