Home
Options

LINQPad not releasing memory

I get frequent out of memory exceptions. Those are my fault as to big queries are run and I can fix them. However I realized that if the script exits with an out of memory exception, LINQPad does not free up this memory. Only if I close the tab the memory gets released. I think this is a bug, once a script was executed it should be removed from memory and all ressources released.

Comments

  • Options
    Another way to release the query's memory is to use the option on the Query menu to recycle the app domain (Shift+Control+F5).

    In the next build, I'll make LINQPad do this automatically when it encounters an OutOfMemoryException.
  • Options
    I am not sure that I would want it to release all my objects cached using Util.Cache even if it gets an OutOfMemoryException during the execution of the remainder of the query using objects that would get garbage collected anyway. I have pretty big domain objects that are have a big memory footprint and they take minutes to build. Util.Cache was huge win for me.
  • Options
    If you set 'Always preserve app domains' to true in Edit | Preferences | Advanced, LINQPad won't clear the app domain even in case of an OutOfMemoryException.
  • Options
    Hi,
    Is it possible to recycle the app domain (Shift+Control+F5) from code?
  • Options
    Good idea: the following will force a new process in the next LINQPad build: Util.NewProcess = true.
  • Options
    In 4.55.03, Util.NewProcess = true does not appear to work. Or, else I have a bad understanding of it.

    I've written a loop whose contents attempt to construct a query using start / end date parameters. Since I want format the results twice, I used Util.Cache to preserve them. However, despite setting Util.NewProcess to true, each iteration of the loop, despite attempting build a new query with the loop with new date values, the query continues to return the cached results.

    Is this a misunderstanding on my part (quite possible)? A bug with Util.NewProcess?
  • Options
    Try running the following:
    Util.NewProcess = true;
    Process.GetCurrentProcess().Id.Dump();
    Do you get a different number each time you execute it?
Sign In or Register to comment.