Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8837513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:44:40+00:00 2026-06-14T09:44:40+00:00

We have a sql server 2008 box. On this server we have a scheduled

  • 0

We have a sql server 2008 box.
On this server we have a scheduled job that calls a large stored procedure that opens xml files and loads them into tables.

After an extended period of up time the SQL server consumes literally all the available memory. (in fact the page file nearly ate all the disc space)

Is it possible for a stored proc to leak memory?
Is it possible for an SSIS package to leak memory?

Thanks in advance!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T09:44:41+00:00Added an answer on June 14, 2026 at 9:44 am

    Yes, a memory leak is possible if you forget to call sp_xml_removedocument (for each matching sp_xml_preparedocument):

    A parsed document is stored in the internal cache of SQL Server. The
    MSXML parser (Msxmlsql.dll) uses one-eighth the total memory available
    for SQL Server. To avoid running out of memory, run
    sp_xml_removedocument to free up the memory.

    Example usage:

    DECLARE @xml_text VARCHAR(4000), @i INT
    
    SELECT @xml_text = '<root>
                          ... some valid xml ... 
                        </root>'
    
    EXEC sp_xml_preparedocument @i OUTPUT, @xml_text
    
    ....
    
    EXEC sp_xml_removedocument @i
    

    Another form of memory leak is forgetting to both close and deallocate a cursor:

    DECLARE c CURSOR   
      LOCAL STATIC FORWARD_ONLY READ_ONLY   
      FOR SELECT ...
    
        ....
    
    CLOSE c; 
    DEALLOCATE c;
    

    [Note: I rarely use cursors. Wherever possible and appropriate I always try to do it the set-based way]

    Just for the record, even though I always like to see an explicit CLOSE and DEALLOCATE for cursors:

    LOCAL cursors are implicitly deallocated when the stored procedure,
    trigger, or batch in which they were created terminates, unless the
    cursor has been passed back as a parameter. The LOCAL cursor will then
    be implicitly deallocated when the parameter or variable referencing
    the cursor in the code that called the procedure goes out scope.
    Ref.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Access 2003 database that connects to a SQL Server 2008 box
I have SQL Server 2008 with a table called ProductCategories designed like this: Id
I have an SQL Server 2008 database with a table that has a column
I have a SQL Server 2008 database which contains data that I need to
I have an SSIS package deployed to Sql Server 2008. This package runs fine
I have an ASP.NET MVC Web Application that interacts with a SQL Server 2008
I have a freshly built 64-bit Windows Server 2008 R2 box that I have
I have an .mdf file on my local box. I have SQL Server 2008
We have SQL Server 2008 R2 and Visual Studio 2008. I have used the
I have SQL Server 2008 and VS 2008 Pro. And I am coding in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.