• dlevin (2/14/2014)


    Spring Town -

    Thanks for this great explanation. I have a question...

    You write "You're on the right track as far as the memory clerks go. Watch them over time. Does the SQLCLR clerk keep rising higher and higher until getting killed? Also consider watching the other non-buffer pool memory clerks for any abnormally large memory allocations."

    so if that indeed does happen, where the memory usage goes higher and higher until it gets killed, what does that mean exactly? Can we presume we have a leak? We're running a CLR assembly that when run, the clerk keeps rising. When we stop running it, the clerk remains steady. The clerk doesnt decrease until a restart or the app domain error occurs. Is there a way in the code to clean up the memory space?

    Thanks

    Sounds like a memory leak. I am not sure of all the ways that could happen in .Net, but I do know that if you are not cleaning up managed resources then it would have that effect as the references to those objects will get orphaned when the process ends. If that happens then the objects can't be disposed and garbage collection will never pick them up.

    What is your code doing? Are you accessing any external resources or streams? Are you using any SqlConnection or SqlDataReader classses, or anything like that? If so, all of those references need to be closed (i.e. call the .Close() method), typically in a finally block (just in case there is an exception, the cleanup still happens). If they are not closed then the resources stay allocated and that will take up more and more memory. And if not using a finally block, or at least repeating the close statement(s) in a catch block and errors occur, then that would have the same effect.

    Does this make sense and possibly fit your situation? If not, can you please share a little more about what your code is doing?

    Take care,

    Solomon.

    SQL#https://SQLsharp.com/ ( SQLCLR library ofover 340 Functions and Procedures)
    Sql Quantum Lifthttps://SqlQuantumLift.com/ ( company )
    Sql Quantum Leaphttps://SqlQuantumLeap.com/ ( blog )
    Info sitesCollations     •     Module Signing     •     SQLCLR