Skip to content

Memory leak when there are SVG elements with foreignObject elements #656

@eturpin

Description

@eturpin

There seems to be a memory leak that occurs when SVG elements are nested inside foreignObject elements. A "garbage collector" was created to fix #241, but I don't think SVG elements within foreignObject elements will ever be removed from the hub object. foreignObjects will not have a ownerSVGElement property defined, so the delete hub[key]; line will never be executed in the garbage collector.

Would replacing this line in the garbage collector:

if (el.type != "svg" && !node.ownerSVGElement || el.type == "svg" && (!node.parentNode || "ownerSVGElement" in node.parentNode && !node.ownerSVGElement))

with

if (!node.isConnected)

be a suitable solution?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions