Skip to content

Commit 5bb75fa

Browse files
committed
null out builders at the end of code generation to avoid context memory leaks
1 parent 9845474 commit 5bb75fa

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/dotty/tools/dotc/backend/jvm/GenBCode.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ object GenBCode extends BCodeSyncAndTry {
5959
override def description = "Generate bytecode from ASTs using the ASM library"
6060
// override def erasedTypes = true // TODO(lrytz) remove, probably not necessary in dotty
6161

62-
private var bytecodeWriter : BytecodeWriter = null
63-
// TODO(lrytz): pass builders around instead of storing them in fields. Builders
62+
// TODO(lrytz): pass writer and builders around instead of storing them in fields. They
6463
// have a context, potential for memory leaks.
64+
private var bytecodeWriter : BytecodeWriter = null
6565
private var mirrorCodeGen : JMirrorBuilder = null
6666
private var beanInfoCodeGen : JBeanInfoBuilder = null
6767

@@ -298,8 +298,10 @@ object GenBCode extends BCodeSyncAndTry {
298298
// clearing maps
299299
clearBCodeTypes()
300300

301-
// free the Context instance reachable from BytecodeWriter
301+
// free the reachable Context instances
302302
bytecodeWriter = null
303+
mirrorCodeGen = null
304+
beanInfoCodeGen = null
303305
}
304306

305307
override def run(implicit ctx: Context): Unit = unsupported("run()")

0 commit comments

Comments
 (0)