Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/empty-poets-wait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@tanstack/db-ivm": patch
---

Fix memory leak that results in linear memory growth with incremental changes over time. Thanks to @sorenbs for finding and fixing this.
7 changes: 0 additions & 7 deletions packages/db-ivm/src/d2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import type { MultiSet, MultiSetArray } from "./multiset.js"
import type { ID2, IStreamBuilder, PipedOperator } from "./types.js"

export class D2 implements ID2 {
#streams: Array<DifferenceStreamReader<any>> = []
#operators: Array<UnaryOperator<any> | BinaryOperator<any>> = []
#nextOperatorId = 0
#finalized = false
Expand All @@ -31,7 +30,6 @@ export class D2 implements ID2 {
const writer = new DifferenceStreamWriter<T>()
// Use the root stream builder that exposes the sendData and sendFrontier methods
const streamBuilder = new RootStreamBuilder<T>(this, writer)
this.#streams.push(streamBuilder.connectReader())
return streamBuilder
}

Expand All @@ -40,11 +38,6 @@ export class D2 implements ID2 {
this.#operators.push(operator)
}

addStream(stream: DifferenceStreamReader<any>): void {
this.#checkNotFinalized()
this.#streams.push(stream)
}

finalize() {
this.#checkNotFinalized()
this.#finalized = true
Expand Down
1 change: 0 additions & 1 deletion packages/db-ivm/src/operators/concat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export function concat<T, T2>(
output.writer
)
stream.graph.addOperator(operator)
stream.graph.addStream(output.connectReader())
return output
}
}
1 change: 0 additions & 1 deletion packages/db-ivm/src/operators/consolidate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export function consolidate<T>(): PipedOperator<T, T> {
output.writer
)
stream.graph.addOperator(operator)
stream.graph.addStream(output.connectReader())
return output
}
}
1 change: 0 additions & 1 deletion packages/db-ivm/src/operators/count.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export function count<
output.writer
)
stream.graph.addOperator(operator)
stream.graph.addStream(output.connectReader())
return output
}
}
1 change: 0 additions & 1 deletion packages/db-ivm/src/operators/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export function debug<T>(
indent
)
stream.graph.addOperator(operator)
stream.graph.addStream(output.connectReader())
return output
}
}
1 change: 0 additions & 1 deletion packages/db-ivm/src/operators/distinct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ export function distinct<T>(by: (value: T) => any = (value: T) => value) {
by
)
stream.graph.addOperator(operator)
stream.graph.addStream(output.connectReader())
return output
}
}
1 change: 0 additions & 1 deletion packages/db-ivm/src/operators/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export function filter<T>(f: (data: T) => boolean): PipedOperator<T, T> {
f
)
stream.graph.addOperator(operator)
stream.graph.addStream(output.connectReader())
return output
}
}
1 change: 0 additions & 1 deletion packages/db-ivm/src/operators/join.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ export function innerJoin<
output.writer
)
stream.graph.addOperator(operator)
stream.graph.addStream(output.connectReader())
return output
}
}
Expand Down
1 change: 0 additions & 1 deletion packages/db-ivm/src/operators/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export function map<T, O>(f: (data: T) => O): PipedOperator<T, O> {
f
)
stream.graph.addOperator(operator)
stream.graph.addStream(output.connectReader())
return output
}
}
1 change: 0 additions & 1 deletion packages/db-ivm/src/operators/negate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export function negate<T>(): PipedOperator<T, T> {
output.writer
)
stream.graph.addOperator(operator)
stream.graph.addStream(output.connectReader())
return output
}
}
1 change: 0 additions & 1 deletion packages/db-ivm/src/operators/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export function output<T>(
fn
)
stream.graph.addOperator(operator)
stream.graph.addStream(outputStream.connectReader())
return outputStream
}
}
1 change: 0 additions & 1 deletion packages/db-ivm/src/operators/reduce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ export function reduce<
f
)
stream.graph.addOperator(operator)
stream.graph.addStream(output.connectReader())
return output
}
}
1 change: 0 additions & 1 deletion packages/db-ivm/src/operators/tap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export function tap<T>(f: (data: MultiSet<T>) => void): PipedOperator<T, T> {
f
)
stream.graph.addOperator(operator)
stream.graph.addStream(output.connectReader())
return output
}
}
1 change: 0 additions & 1 deletion packages/db-ivm/src/operators/topKWithFractionalIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@ export function topKWithFractionalIndex<KType, T>(
opts
)
stream.graph.addOperator(operator)
stream.graph.addStream(output.connectReader())
return output
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,6 @@ export function topKWithFractionalIndexBTree<KType, T>(
opts
)
stream.graph.addOperator(operator)
stream.graph.addStream(output.connectReader())
return output
}
}
1 change: 0 additions & 1 deletion packages/db-ivm/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export interface ID2 {
getNextOperatorId: () => number
newInput: <T>() => IStreamBuilder<T>
addOperator: (operator: UnaryOperator<any> | BinaryOperator<any>) => void
addStream: (stream: DifferenceStreamReader<any>) => void
finalize: () => void
step: () => void
}
Expand Down
Loading