1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-26 20:01:15 +02:00

Add a function ‘valueSize’

It returns the size of value, including all other values and
environments reachable from it. It is intended for debugging memory
consumption issues.
This commit is contained in:
Eelco Dolstra 2014-09-22 14:46:42 +02:00
parent 68cf98c4d2
commit eff120d1b9
4 changed files with 99 additions and 2 deletions

View file

@ -423,6 +423,13 @@ void prim_gcCanary(EvalState & state, const Pos & pos, Value * * args, Value & v
}
void prim_valueSize(EvalState & state, const Pos & pos, Value * * args, Value & v)
{
/* We're not forcing the argument on purpose. */
mkInt(v, valueSize(*args[0]));
}
/*************************************************************
* Derivations
*************************************************************/
@ -1416,8 +1423,11 @@ void EvalState::createBaseEnv()
addPrimOp("__addErrorContext", 2, prim_addErrorContext);
addPrimOp("__tryEval", 1, prim_tryEval);
addPrimOp("__getEnv", 1, prim_getEnv);
// Debugging
addPrimOp("__trace", 2, prim_trace);
addPrimOp("__gcCanary", 1, prim_gcCanary);
addPrimOp("__valueSize", 1, prim_valueSize);
// Paths
addPrimOp("__toPath", 1, prim_toPath);