mirror of
https://github.com/NixOS/nix.git
synced 2025-11-12 21:46:01 +01:00
libexpr: Clear PosTable contents in EvalState::resetFileCache
Otherwise PosTable grows indefinitely for each reload. Since the total input size is limited to 4GB (uint32_t for byte offset PosIdx) it can get exhausted pretty. This ensures that we don't waste memory on reloads as well.
This commit is contained in:
parent
479b6b73a9
commit
a091a8100a
2 changed files with 11 additions and 0 deletions
|
|
@ -1113,6 +1113,7 @@ void EvalState::resetFileCache()
|
||||||
importResolutionCache->clear();
|
importResolutionCache->clear();
|
||||||
fileEvalCache->clear();
|
fileEvalCache->clear();
|
||||||
inputCache->clear();
|
inputCache->clear();
|
||||||
|
positions.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EvalState::eval(Expr * e, Value & v)
|
void EvalState::eval(Expr * e, Value & v)
|
||||||
|
|
|
||||||
|
|
@ -111,6 +111,16 @@ public:
|
||||||
return o->origin;
|
return o->origin;
|
||||||
return std::monostate{};
|
return std::monostate{};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove all origins from the table.
|
||||||
|
*/
|
||||||
|
void clear()
|
||||||
|
{
|
||||||
|
auto lines = linesCache.lock();
|
||||||
|
lines->clear();
|
||||||
|
origins.clear();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace nix
|
} // namespace nix
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue