locked
Managed and Un-Managed Code RRS feed

  • Question

  • Good day to all of you I just want to ask a deeper explanation abou the managed and un-managed code.

    I'am using sql server 2014 and I wrote T-sql stored procedure, suddenly I read that writing T-sql with logical and functionality will compromise computer memory is  that true?

    Other Question Does T-sql is un - manged code? and Visual Studio 6 is also un-manged code? 

    Thank you in advance


    • Edited by Shanky_621MVP Monday, April 11, 2016 8:57 AM spelling and grammar
    Monday, April 11, 2016 6:39 AM

Answers

  • Greetings TinVin,

    I hope someone will rectify me or aknowledge me on this one but per my knowledge:

    Clarification:

    CLR functions are "unmanaged" code in the sense that they're outside the visibility of SQL-Server.
    This is why you have the waittypes with 'CLR' in it to monitor that they're in a CLR-process and also the flag 'Executing_Managed_Code' in the DM_Exec_Requests.

    Heck you can even ask how long they spend in CLR-code but asking the view dm_exec_query_stats (qs.total_clr_time) but you will never be able to ask an CLR-function what its currently executing from SQL-Server.

    (edit: Before SQL 2012: It does seem CLR's execute within the memory-allocation of SQL-server so you can watch the query's allocation grow/shrink.. today I learned)

    programming paradigm:

    However if you look at the difference of Managed (C#) or Unmanaged (Unsafe / C++) code when coming from a programming-paradigm..
    It still upholds the carbage-collection from the windows-systems as you have per a regular C# program.
    This means you don't have to explicitly remove old-objects in code but you can let the background process do this.

    Lastly; Visual Studio (6) supports creating managed and unmanaged code but for the unmanaged-code the programmer explicitly has to mark it as such.

    with kind regards,

    Sebastian

    ps. thanks for the question; made an interesting read to check my facts :)




    • Edited by Sebastian vd Putten Monday, April 11, 2016 8:32 AM Extended: Today i learned.
    • Marked as answer by TinVin727 Tuesday, April 12, 2016 12:44 AM
    Monday, April 11, 2016 7:43 AM
  • I'am using sql server 2014 and I wrote T-sql stored procedure, suddenly I read that writing T-sql with logical and functionality will compromise computer memory is  that true?

    Other Question Does T-sql is un - manged code? and Visual Studio 6 is also un-manged code? 

    Thank you in advance


    Hi

    And where did you read that it would compromise it. Can you show me the article/link/book. I am sure this is not the case. Windows do not do direct memory allocation the process is first mapped to its VAS (virtual address space) and then to physical memory. VAS acts as layer of abstraction. This protects the direct access and hence security

    A virtual address does not represent the actual physical location of an object in memory; instead, the system maintains a page table for each process, which is an internal data structure used to translate virtual addresses into their corresponding physical addresses. Each time a thread references an address, the system translates the virtual address to a physical address.

    SQL Server TSQL  is not an unmanaged code. But it can call certain components which use unmanaged code. Un managed code is Code that runs outside the CLR is referred to as "unmanaged code." COM components, ActiveX components, and Win32 API functions are examples of unmanaged code.


    Cheers,

    Shashank

    Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it

    My TechNet Wiki Articles

    MVP

    • Marked as answer by TinVin727 Tuesday, April 12, 2016 12:44 AM
    Monday, April 11, 2016 9:10 AM

All replies

  • Greetings TinVin,

    I hope someone will rectify me or aknowledge me on this one but per my knowledge:

    Clarification:

    CLR functions are "unmanaged" code in the sense that they're outside the visibility of SQL-Server.
    This is why you have the waittypes with 'CLR' in it to monitor that they're in a CLR-process and also the flag 'Executing_Managed_Code' in the DM_Exec_Requests.

    Heck you can even ask how long they spend in CLR-code but asking the view dm_exec_query_stats (qs.total_clr_time) but you will never be able to ask an CLR-function what its currently executing from SQL-Server.

    (edit: Before SQL 2012: It does seem CLR's execute within the memory-allocation of SQL-server so you can watch the query's allocation grow/shrink.. today I learned)

    programming paradigm:

    However if you look at the difference of Managed (C#) or Unmanaged (Unsafe / C++) code when coming from a programming-paradigm..
    It still upholds the carbage-collection from the windows-systems as you have per a regular C# program.
    This means you don't have to explicitly remove old-objects in code but you can let the background process do this.

    Lastly; Visual Studio (6) supports creating managed and unmanaged code but for the unmanaged-code the programmer explicitly has to mark it as such.

    with kind regards,

    Sebastian

    ps. thanks for the question; made an interesting read to check my facts :)




    • Edited by Sebastian vd Putten Monday, April 11, 2016 8:32 AM Extended: Today i learned.
    • Marked as answer by TinVin727 Tuesday, April 12, 2016 12:44 AM
    Monday, April 11, 2016 7:43 AM
  • I'am using sql server 2014 and I wrote T-sql stored procedure, suddenly I read that writing T-sql with logical and functionality will compromise computer memory is  that true?

    Other Question Does T-sql is un - manged code? and Visual Studio 6 is also un-manged code? 

    Thank you in advance


    Hi

    And where did you read that it would compromise it. Can you show me the article/link/book. I am sure this is not the case. Windows do not do direct memory allocation the process is first mapped to its VAS (virtual address space) and then to physical memory. VAS acts as layer of abstraction. This protects the direct access and hence security

    A virtual address does not represent the actual physical location of an object in memory; instead, the system maintains a page table for each process, which is an internal data structure used to translate virtual addresses into their corresponding physical addresses. Each time a thread references an address, the system translates the virtual address to a physical address.

    SQL Server TSQL  is not an unmanaged code. But it can call certain components which use unmanaged code. Un managed code is Code that runs outside the CLR is referred to as "unmanaged code." COM components, ActiveX components, and Win32 API functions are examples of unmanaged code.


    Cheers,

    Shashank

    Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it

    My TechNet Wiki Articles

    MVP

    • Marked as answer by TinVin727 Tuesday, April 12, 2016 12:44 AM
    Monday, April 11, 2016 9:10 AM