Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Activator.CreateInstance() and JITing

Activator.CreateInstance() and JITing

Scheduled Pinned Locked Moved .NET (Core and Framework)
questiondiscussion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jarrod Marshall
    wrote on last edited by
    #1

    Let's say I have 3 classes. Class 1 needs to create an instance of Class 2 or Class 3 depending on some evaluation. All three classes reside within the same assembly. When Activator.CreateInstance() is called does the loaded type get re-jitted even though the caller is in fact the same assembly and has already been jitted? Just wondering :) Any thoughts on this would be appreciated!!! Jarrod

    J 1 Reply Last reply
    0
    • J Jarrod Marshall

      Let's say I have 3 classes. Class 1 needs to create an instance of Class 2 or Class 3 depending on some evaluation. All three classes reside within the same assembly. When Activator.CreateInstance() is called does the loaded type get re-jitted even though the caller is in fact the same assembly and has already been jitted? Just wondering :) Any thoughts on this would be appreciated!!! Jarrod

      J Offline
      J Offline
      James T Johnson
      wrote on last edited by
      #2

      JarrodM wrote: When Activator.CreateInstance() is called does the loaded type get re-jitted even though the caller is in fact the same assembly and has already been jitted? Unless you run the ngen utility on your assembly, JITting takes place on a method by method basis. So the JIT should only occur once per method. James - out of order -

      J 1 Reply Last reply
      0
      • J James T Johnson

        JarrodM wrote: When Activator.CreateInstance() is called does the loaded type get re-jitted even though the caller is in fact the same assembly and has already been jitted? Unless you run the ngen utility on your assembly, JITting takes place on a method by method basis. So the JIT should only occur once per method. James - out of order -

        J Offline
        J Offline
        Jarrod Marshall
        wrote on last edited by
        #3

        So each time I call a method for the first time on one of these classes newly instantiated by reflection it will JIT? Jarrod

        J 1 Reply Last reply
        0
        • J Jarrod Marshall

          So each time I call a method for the first time on one of these classes newly instantiated by reflection it will JIT? Jarrod

          J Offline
          J Offline
          James T Johnson
          wrote on last edited by
          #4

          Sorry, I meant to add that bit in but forgot :-O This part is tricky for me to word so please accept my apologies before hand. JITting occurs when one of a few things happen: A method is being run for the first time, the underlying IL of an already JITted method has changed, or in certain circumstances the native code produced by ngen will be ignored (ASP.NET is one case). There are also some Debug/Profiling methods that will perfrom a re-JIT. Unless you are causing the JIT by running ngen, the native code generated will be tossed out after the Assembly has been unloaded. The native code generated is also AppDomain specific, so if you have two AppDomains each loading the same assembly then each method will be JITted once for each AppDomain. Now in your case, the JIT will only occur the first time each method is used, regardless of whether the object using that method is created by Reflection or regular code. James - out of order -

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups