[ExtendScript] never releases PathPoint objects so scripts slow down.
ExtendScript never releases PathPoint objects, so scripts slow down until Illustrator restarts
Versions: Illustrator Beta 31.0.0, macOS 26.7.1. Also reported in Illustrator 2026 on Windows (community thread).
Summary
When a script gets a path point (pathItem.pathPoints[i]), ExtendScript creates a PathPoint object, plus a PathPoints object for the collection and an Array for .anchor. None of these are ever released. As they build up, every later script in that engine gets slower, including scripts that never touch path points. Only quitting Illustrator clears them.
Steps to reproduce
- Run the script below from File > Scripts in a freshly launched Illustrator.
- Run it again a few more times.
(function () {
var doc = app.documents.add();
function countOf(type) {
var match = $.summary().match(new RegExp('^\\s*(\\d+) ' + type + '$', 'm'));
return match ? Number(match[1]) : 0;
};
// fixed job that never touches path points: make 1,500 rectangles, read bounds, set stroke, delete them
function job() {
var t0 = new Date().getTime();
var layer = doc.layers.add();
var refs = [];
var i;
for (i = 0; i < 1500; i++)
refs.push(layer.pathItems.rectangle(-(i % 50) * 3, Math.floor(i / 50) * 3, 2, 2));
for (i = 0; i < refs.length; i++) {
var b = refs[i].geometricBounds;
refs[i].strokeWidth = 0.5;
}
layer.remove();
return new Date().getTime() - t0;
};
// make 6,000 rectangles, read every anchor (24,000 points), delete them
function readPoints() {
var layer = doc.layers.add();
for (var i = 0; i < 6000; i++) {
var pp = layer.pathItems.rectangle(-(i % 50) * 3, Math.floor(i / 50) * 3, 2, 2).pathPoints;
for (var k = 0; k < pp.length; k++)
var a = pp[k].anchor;
}
layer.remove();
};
var before = job();
readPoints();
$.gc();
var after = job();
doc.close(SaveOptions.DONOTSAVECHANGES);
$.gc();
var message = 'Job: ' + before + ' ms before, ' + after + ' ms after.\n'
+ 'Still alive after deleting shapes, closing the document and $.gc():\n'
+ countOf('PathPoint') + ' PathPoint, ' + countOf('PathPoints') + ' PathPoints, '
+ countOf('PathItem') + ' PathItem.';
alert(message);
})();
Expected
Once the shapes are deleted, the document is closed and $.gc() has run, the PathPoint and PathPoints counts drop back to 0, as the PathItem count does. The job takes the same time on every run.
Actual
- The
PathItemcount returns to 0, but everyPathPoint,PathPointsand anchorArraystays alive. Each run adds 24,000 more. - Reading the same point twice adds nothing, so each point gets one object, cached and never freed.
- The fixed job, which never reads a point, gets slower with every run and stays slow:
| Run | Job | Reading 24,000 points | Live PathPoint objects |
|---|---|---|---|
| Control, no point reading | 27–43 ms | — | 1,600 |
| 1 | 117 ms | 1,070 ms | 25,600 |
| 2 | 262 ms | 4,095 ms | 49,600 |
| 3 | 333 ms | 4,728 ms | 73,600 |
| Control again, no point reading | 294–464 ms | — | 97,600 |
Things that don't release the objects
- Deleting the shapes, setting every reference to
null, and calling$.gc()repeatedly. - Closing the document without saving.
- Also reported on Windows: undoing back to an empty document, removing the points first (
pathPoint.remove()/pathPoints.removeAll()), and waiting 5 to 30 seconds. It happens in CEP panel engines as well as the main engine. Just taking a point (var p = pp[i]) without reading any property creates the object.
Impact
This affects any script that reads many path points (cleanup, comparison or measuring tools) and every script run after it in the same session. Today the only fix is to restart Illustrator.
Requests
- Release
PathPoint/PathPointsobjects when they are no longer referenced, or at least when their path is deleted. - Provide a way to read a path's points in bulk as plain numbers, so no
PathPointobject is created for each point. Today there isn't one:toSource(),uneval()andString()don't return coordinates.
Bug was noticed by forum user Glenn Wilton (link to post above) and report was drafted by Claude Opus 5.5.