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. CLR

CLR

Scheduled Pinned Locked Moved .NET (Core and Framework)
dotnetdata-structuresquestion
28 Posts 6 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.
  • L Luc Pattyn

    Hi Colin,

    Colin Angus Mackay wrote:

    Microsoft is a business. It is their job to make money and they happen to be very good at it.

    I agree. But I would like them to be a little better at offering things that make life easy for programmers/developers, even if that would (seem to) take away one percent of their profits. Why are line numbers not displayed by default in Visual source files ? Why does Windows show a silly error number when trying to run a .NET app on a system that does not have (the right version of) .NET installed ? Why don't they provide a full set of P/Invoke prototypes for all Win32 structures and functions ? Why does it take a network guru to set up a wireless network ? (are there any non-technical people who get any level of security?) Why do we have to view or enter stuff in 200*200 pixel windows and dropdowns, when the screen has over 1M pixel ? Why does most MSDN documentation on API stuff come without examples ? Why don't they provide a list of probable causes, in non-academic terms, for the most frequently occuring error situations ? ... the list is infinite. In general, is it so hard to listen to users and to read forums (like this one) and learn from it, as to how the user's experience could be improved (rather than just adding features, complexity and sometimes mystery). In my opinion most of what goes on on these forums should be made redundant by step-by-step improvements to the MS products and their documentation. Conclusion: as long as dollars/euros/yens seem to be more important than customers and their little problems, I tend to occasionally replace an 's' by a '$' Regards

    Luc Pattyn [Forum Guidelines] [My Articles]


    this weeks tips: - make Visual display line numbers: Tools/Options/TextEditor/... - show exceptions with ToString() to see all information - before you ask a question here, search CodeProject, then Google


    C Offline
    C Offline
    Colin Angus Mackay
    wrote on last edited by
    #13

    Gosh! That's not what I see at all. Microsoft are very responsive for such a large company and they do try their best for the community. They are improving constantly, it just takes time. For instance, there are a lot more examples in MSDN than their used to be. There are a lot of new and innovative things on the horizon which I am sure will address some of your concerns.


    Upcoming FREE developer events: * Glasgow: Agile in the Enterprise Vs. ISVs, Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ... * Reading: SQL Bits My website

    1 Reply Last reply
    0
    • L Luc Pattyn

      A stack is a data structure where things get added on one end, in a particular order, and get removed, at the same end, in reverse order. That is the only thing a stack is capable of (and it is very good at that). you can't allocate reference types on a stack: the stack is used for keeping track of program flow (calling and returning from methods) and for local value types (which live as long as the method is executing). If you return from a method, the stack is reset to the state it had when you entered the method, that is the only thing acceptable to the calling method. Ref types must live from construction (with new) until death (last reference got lost); they don't die in reverse order of construction, and they get constructed and die independent of program flow, hence there is no room whatsoever to allocate ref types on the stack. In summary: a system can not allocate ref types on the stack. It needs separate memory to hold them, such memory is called a heap. Actually ref types come from a couple of heaps, depending on the size of the objects (small objects get shuffled around to avoid heap fragmentation, large objects come from the large object heap, which is not reshuffled, and may get exhausted due to fragmentation, something Micro$oft tries not to focus your attention on). :)

      Luc Pattyn [Forum Guidelines] [My Articles]


      this weeks tips: - make Visual display line numbers: Tools/Options/TextEditor/... - show exceptions with ToString() to see all information - before you ask a question here, search CodeProject, then Google


      M Offline
      M Offline
      MarKus0
      wrote on last edited by
      #14

      So, it's the OS that allocate space on the stack for the process?! If it's so, I think that can't exists a (new) CLR that manage stack..!? I understand that for my question, CLR would have to do the work of OS; so i would have to change OS too; is it that? Then arise one question on C#: namespace Simple { class Program { static void Main(string[] args) { Console.WriteLine("that's the program"); int a = 0; myClass mc = new myClass(); } } } I read that every value type (int32, enumeration, and other) are on the stack; but if they're inside a class declaration they take part of object and then go on the heap. In c# even main is inside a class (in my example " Program"); with this knowledge, it seems to me that evey things goes on the heap. Could you explain to me what go on the stack ? (use my example code, please) Thanks...

      L D 2 Replies Last reply
      0
      • M MarKus0

        So, it's the OS that allocate space on the stack for the process?! If it's so, I think that can't exists a (new) CLR that manage stack..!? I understand that for my question, CLR would have to do the work of OS; so i would have to change OS too; is it that? Then arise one question on C#: namespace Simple { class Program { static void Main(string[] args) { Console.WriteLine("that's the program"); int a = 0; myClass mc = new myClass(); } } } I read that every value type (int32, enumeration, and other) are on the stack; but if they're inside a class declaration they take part of object and then go on the heap. In c# even main is inside a class (in my example " Program"); with this knowledge, it seems to me that evey things goes on the heap. Could you explain to me what go on the stack ? (use my example code, please) Thanks...

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #15

        I already told you what goes on the stack, and why the other things don't fit on a stack. Things are the way they must be. For me the subject is closed. :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        this weeks tips: - make Visual display line numbers: Tools/Options/TextEditor/... - show exceptions with ToString() to see all information - before you ask a question here, search CodeProject, then Google


        P 1 Reply Last reply
        0
        • L Luc Pattyn

          I already told you what goes on the stack, and why the other things don't fit on a stack. Things are the way they must be. For me the subject is closed. :)

          Luc Pattyn [Forum Guidelines] [My Articles]


          this weeks tips: - make Visual display line numbers: Tools/Options/TextEditor/... - show exceptions with ToString() to see all information - before you ask a question here, search CodeProject, then Google


          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #16

          No - let him implement the OS as well. That should be worth seeing.

          Deja View - the feeling that you've seen this post before.

          L 1 Reply Last reply
          0
          • P Pete OHanlon

            No - let him implement the OS as well. That should be worth seeing.

            Deja View - the feeling that you've seen this post before.

            L Offline
            L Offline
            Luc Pattyn
            wrote on last edited by
            #17

            OK, on one condition, Chris should start a separate forum for it, since I expect a couple more discussion threads before the new OS is up and running...

            Luc Pattyn [Forum Guidelines] [My Articles]


            this weeks tips: - make Visual display line numbers: Tools/Options/TextEditor/... - show exceptions with ToString() to see all information - before you ask a question here, search CodeProject, then Google


            P 1 Reply Last reply
            0
            • M MarKus0

              So, it's the OS that allocate space on the stack for the process?! If it's so, I think that can't exists a (new) CLR that manage stack..!? I understand that for my question, CLR would have to do the work of OS; so i would have to change OS too; is it that? Then arise one question on C#: namespace Simple { class Program { static void Main(string[] args) { Console.WriteLine("that's the program"); int a = 0; myClass mc = new myClass(); } } } I read that every value type (int32, enumeration, and other) are on the stack; but if they're inside a class declaration they take part of object and then go on the heap. In c# even main is inside a class (in my example " Program"); with this knowledge, it seems to me that evey things goes on the heap. Could you explain to me what go on the stack ? (use my example code, please) Thanks...

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #18

              MarKus0 wrote:

              So, it's the OS that allocate space on the stack for the process?!

              No, not entirely. The processor has a stack the is allocated on a per-thread basis. Ever here of the Stack Pointer? Read[^] It's the processor that's stopping you from doing what you want, not the .NET Framework or the O/S.

              A guide to posting questions on CodeProject[^]
              Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                   2006, 2007

              P L S 3 Replies Last reply
              0
              • L Luc Pattyn

                OK, on one condition, Chris should start a separate forum for it, since I expect a couple more discussion threads before the new OS is up and running...

                Luc Pattyn [Forum Guidelines] [My Articles]


                this weeks tips: - make Visual display line numbers: Tools/Options/TextEditor/... - show exceptions with ToString() to see all information - before you ask a question here, search CodeProject, then Google


                P Offline
                P Offline
                Pete OHanlon
                wrote on last edited by
                #19

                Seems fair. He'll need a cool name for the project though. How about calling it "Pillock" or "Idiot"? That way we can ask people "Are you running Idiot?"

                Deja View - the feeling that you've seen this post before.

                L 1 Reply Last reply
                0
                • D Dave Kreskowiak

                  MarKus0 wrote:

                  So, it's the OS that allocate space on the stack for the process?!

                  No, not entirely. The processor has a stack the is allocated on a per-thread basis. Ever here of the Stack Pointer? Read[^] It's the processor that's stopping you from doing what you want, not the .NET Framework or the O/S.

                  A guide to posting questions on CodeProject[^]
                  Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                       2006, 2007

                  P Offline
                  P Offline
                  Pete OHanlon
                  wrote on last edited by
                  #20

                  Dave - don't let facts get in the way of our mocking him.

                  Deja View - the feeling that you've seen this post before.

                  D 1 Reply Last reply
                  0
                  • D Dave Kreskowiak

                    MarKus0 wrote:

                    So, it's the OS that allocate space on the stack for the process?!

                    No, not entirely. The processor has a stack the is allocated on a per-thread basis. Ever here of the Stack Pointer? Read[^] It's the processor that's stopping you from doing what you want, not the .NET Framework or the O/S.

                    A guide to posting questions on CodeProject[^]
                    Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                         2006, 2007

                    L Offline
                    L Offline
                    Luc Pattyn
                    wrote on last edited by
                    #21

                    Dave Kreskowiak wrote:

                    It's the processor that's stopping you from doing what you want, not the .NET Framework or the O/S.

                    IMO that is not entirely true; this is how I see it: - most processors don't support heaps at all, yet lots of OS need heaps, so these get implemented by software; - stack structures can be implemented by software (e.g. the Stack class in .NET); - there (still) are processors that don't provide hardware support for a stack, yet a stack-based language (and OS) can made to run on them; when they have say a shadow register for PC (into which the PC gets copied upon CALL or INT), each function must start saving the shadow PC on a software stack; - alternatively, if the CPU offers stack support (i.e. pushes the PC to a memory location thru a pointing register) and you don't like the way it works, you can undo it by software, and keep track of program flow in some other way. - IIRC Intel's IA432 architecture did not have real stack support, instead it allocated nodes (on the heap!) that got linked back and forth, resulting in a distributed structure with stack behavior. So I would say most OS really want to have hardware supporting a stack, and hence most chip vendors provide exactly that, but either one can choose to do it differently (which they seldom do). :)

                    Luc Pattyn [Forum Guidelines] [My Articles]


                    this weeks tips: - make Visual display line numbers: Tools/Options/TextEditor/... - show exceptions with ToString() to see all information - before you ask a question here, search CodeProject, then Google


                    D 1 Reply Last reply
                    0
                    • P Pete OHanlon

                      Seems fair. He'll need a cool name for the project though. How about calling it "Pillock" or "Idiot"? That way we can ask people "Are you running Idiot?"

                      Deja View - the feeling that you've seen this post before.

                      L Offline
                      L Offline
                      Luc Pattyn
                      wrote on last edited by
                      #22

                      Hmm, learning a least one new word every day now. I like that. :-D

                      Luc Pattyn [Forum Guidelines] [My Articles]


                      this weeks tips: - make Visual display line numbers: Tools/Options/TextEditor/... - show exceptions with ToString() to see all information - before you ask a question here, search CodeProject, then Google


                      1 Reply Last reply
                      0
                      • L Luc Pattyn

                        Dave Kreskowiak wrote:

                        It's the processor that's stopping you from doing what you want, not the .NET Framework or the O/S.

                        IMO that is not entirely true; this is how I see it: - most processors don't support heaps at all, yet lots of OS need heaps, so these get implemented by software; - stack structures can be implemented by software (e.g. the Stack class in .NET); - there (still) are processors that don't provide hardware support for a stack, yet a stack-based language (and OS) can made to run on them; when they have say a shadow register for PC (into which the PC gets copied upon CALL or INT), each function must start saving the shadow PC on a software stack; - alternatively, if the CPU offers stack support (i.e. pushes the PC to a memory location thru a pointing register) and you don't like the way it works, you can undo it by software, and keep track of program flow in some other way. - IIRC Intel's IA432 architecture did not have real stack support, instead it allocated nodes (on the heap!) that got linked back and forth, resulting in a distributed structure with stack behavior. So I would say most OS really want to have hardware supporting a stack, and hence most chip vendors provide exactly that, but either one can choose to do it differently (which they seldom do). :)

                        Luc Pattyn [Forum Guidelines] [My Articles]


                        this weeks tips: - make Visual display line numbers: Tools/Options/TextEditor/... - show exceptions with ToString() to see all information - before you ask a question here, search CodeProject, then Google


                        D Offline
                        D Offline
                        Dave Kreskowiak
                        wrote on last edited by
                        #23

                        I was speaking from the Intel/AMD perspective, which does support execution stacks.

                        Luc Pattyn wrote:

                        - alternatively, if the CPU offers stack support (i.e. pushes the PC to a memory location thru a pointing register) and you don't like the way it works, you can undo it by software, and keep track of program flow in some other way.

                        I don't think he's up to the task of re-writing the O/S just yet! :-D

                        A guide to posting questions on CodeProject[^]
                        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                             2006, 2007

                        1 Reply Last reply
                        0
                        • P Pete OHanlon

                          Dave - don't let facts get in the way of our mocking him.

                          Deja View - the feeling that you've seen this post before.

                          D Offline
                          D Offline
                          Dave Kreskowiak
                          wrote on last edited by
                          #24

                          My bad! :-> Please, proceed. I love a good show! :laugh:

                          A guide to posting questions on CodeProject[^]
                          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                               2006, 2007

                          1 Reply Last reply
                          0
                          • D Dave Kreskowiak

                            MarKus0 wrote:

                            So, it's the OS that allocate space on the stack for the process?!

                            No, not entirely. The processor has a stack the is allocated on a per-thread basis. Ever here of the Stack Pointer? Read[^] It's the processor that's stopping you from doing what you want, not the .NET Framework or the O/S.

                            A guide to posting questions on CodeProject[^]
                            Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                                 2006, 2007

                            S Offline
                            S Offline
                            Sendilkumar M
                            wrote on last edited by
                            #25

                            Guys please answer this..Why value type instances are int stack?

                            M.Sendilkumar

                            D 1 Reply Last reply
                            0
                            • S Sendilkumar M

                              Guys please answer this..Why value type instances are int stack?

                              M.Sendilkumar

                              D Offline
                              D Offline
                              Dave Kreskowiak
                              wrote on last edited by
                              #26

                              I thought we answered this already. Because access to it is much faster than allocating memory on the heap for it, handling the pointer math, copying the values back and forth between memory and a register. On the stack, all that happens to get/set the value is the stack pointer is moved.

                              A guide to posting questions on CodeProject[^]
                              Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                                   2006, 2007

                              1 Reply Last reply
                              0
                              • C Colin Angus Mackay

                                MarKus0 wrote:

                                but will it be possible?

                                No it won't. For the reasons Luc gave. This is a fundamental principle of the way stacks work in computer programs, and it has been pretty much since the first tiem a computer programmer created a subroutine.


                                Upcoming FREE developer events: * Glasgow: Agile in the Enterprise Vs. ISVs, Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ... * Reading: SQL Bits My website

                                M Offline
                                M Offline
                                MarKus0
                                wrote on last edited by
                                #27

                                Hi, I found that code around. Is it possible with managed c++ extension create oblects on the stack???? Does anyone explaim me that? Is this below true? In positive case, what does CLR do to allocate bHeap and bStack (I mean the difference)? thanks value class classB { private: int value; }; classeB^ bHeap = gcnew classeB(); //on managed heap classeB bStack; //on managed stack

                                C 1 Reply Last reply
                                0
                                • M MarKus0

                                  Hi, I found that code around. Is it possible with managed c++ extension create oblects on the stack???? Does anyone explaim me that? Is this below true? In positive case, what does CLR do to allocate bHeap and bStack (I mean the difference)? thanks value class classB { private: int value; }; classeB^ bHeap = gcnew classeB(); //on managed heap classeB bStack; //on managed stack

                                  C Offline
                                  C Offline
                                  Colin Angus Mackay
                                  wrote on last edited by
                                  #28

                                  MarKus0 wrote:

                                  what does CLR do to allocate bHeap and bStack (I mean the difference)?

                                  Why not see for yourself. Why not compile the code then look at the compiled IL through ILDASM (comes with the .NET SDK) or with a tool such as Lutz Roeder's Reflector (a quick google away)


                                  Upcoming FREE developer events: * Glasgow: Agile in the Enterprise Vs. ISVs, db4o: An Embeddable Database Engine for Object-Oriented Environments, Mock Objects, SQL Server CLR Integration, Reporting Services ... My website

                                  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