[swift-dev] Memory leak in swift_EnumCaseName() ?
Paul Menage
paul at paulmenage.org
Fri Jun 30 16:20:56 CDT 2017
(Filed as https://bugs.swift.org/browse/SR-5344)
The following fragment appears to cause memory usage to grow unboundedly:
enum E { case A; case B(String) }
while true { var output = ""; dump(E.A, to: &output) }
I think that the issue is that when swift_EnumCaseName() is called
with an enum type that has multiple cases and at least one object
payload, it leaks a reference on its boxed-Any parameter. Does that
sound plausible?
I don't fully understand how the memory management in the
reflection/mirror code works (Is there a good place to look?) My
assumption is that in that case, the enum requires one word and one
tag bit, which along with the other existential metadata is too big to
be contained entirely in the box, so it's taking a reference on the
box's out-of-line buffer which it is somehow failing to release.
Paul
More information about the swift-dev
mailing list