Skip to content

Memory leak for Signal#select? #164

@kevinresol

Description

@kevinresol

v2.0.2
The following code will go OOM in a few seconds.

using tink.CoreApi;

class Main {
	static final root:Signal<Int> = Signal.trigger();

	static function main() {
		new haxe.Timer(100).run = () -> {
			for (i in 0...1000000)
				root.select(v -> v == 0 ? Some(v) : None);

			trace('heapUsed: ' + Std.int(js.Node.process.memoryUsage().heapUsed / 1024 / 1024) + 'MB');
		}
	}
}

In contrast, if I do it manually with new Signal(cb -> root.handle(v -> if(v == 0) cb(v))); it seems to work fine.

I wonder if I am using it incorrectly or I wrongly expected it to be lazy/suspendable?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions