Skip to content

Commit 8f292b5

Browse files
committed
Merge remote-tracking branch 'origin/mostAbundantMass' into mostAbundantMass
2 parents 2b776be + c9c6182 commit 8f292b5

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

mzLib/Chromatography/RetentionTimePrediction/Chronologer/ChronologerRetentionTimePredictor.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,13 @@ protected override bool ValidateBasicConstraints(IRetentionPredictable peptide,
7575
// Predict retention time - keep both prediction AND disposal inside lock
7676
lock (_modelLock)
7777
{
78-
using var scope = NewDisposeScope(); // dispose forward()'s intermediates deterministically
78+
// Deterministically dispose every tensor created during inference — including the ~30
79+
// intermediates allocated inside the model's forward() (residual clones, conv/norm/relu
80+
// outputs). Without an explicit scope those are reclaimed by the GC finalizer thread, which
81+
// calls into libtorch's native allocator concurrently with the main thread's allocations and
82+
// corrupts the native heap (STATUS_HEAP_CORRUPTION, 0xC0000374) once enough predictions have
83+
// accumulated. The race only surfaces in high-volume runs (e.g. spectral-library builds).
84+
using var scope = NewDisposeScope();
7985
using Tensor prediction = _model.Predict(sequenceTensor).cpu();
8086
return prediction[0].ToDouble();
8187
}

0 commit comments

Comments
 (0)