System.OutOfMemoryException with large script.

Dan GuzmanDan Guzman Posts: 20
edited April 20, 2015 10:39AM in SQL Comparison SDK 11
I successfully performed a data compare and saved the script to a file. My next task to run the script using the C# code below but I get an out of memory error when during the BlockLoader.Load method when try to load a moderately large script (100MB). Is there an alternative method to execute large scripts that avoids this error?
var blockLoader = new RedGate.Shared.SQL.ExecutionBlock.BlockLoader(@"C:MyScriptFile.sql");

            var executionBlock = blockLoader.Load();

            var executor = new RedGate.Shared.SQL.ExecutionBlock.BlockExecutor();

            executor.ExecuteBlock(executionBlock, @".", "MyDatabase", true, "", "");

Thanks,

Dan

Comments

  • Hi Dan,

    I don't know how the BlockLoader.Load method works, but I can imagine that if the script was getting loaded completely into RAM then 100GB could cause a few problems. If you're not already compiling to 64 bit, I'd suggest that you try it to see if it helps, but I don't know it it would completely fix the problem.

    I'll ask the developers to see if I can get some clarification.
    Software Engineer
    Redgate Software
  • Sorry, the 100GB in my post was a typo. It should have been 100MB so I corrected it. My apologies for the confusion.
  • Hi Dan,

    I've double checked with the developers - Blockloader.Load loads the script all at once, so while 100 MB isn't inherently problematic, it does depend on what else is running and how much memory the computer has in total.

    I'd recommend using ANTS Memory Profiler to examine the memory usage of your code in order to find out where the problem is. You'll get a 14 day free trial so that should give you enough time to do some meaningful diagnostics.
    Software Engineer
    Redgate Software
Sign In or Register to comment.