Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
How is a object stored in memory?
 
Are the properties (public/private) stored apart from the methods
 
(i.e. data apart from the executing code, one copy of the method definition IL code)
 
Or bundles are stored separately (i.e. data and method IL code stored together).
 
This could have huge memory implications if you need to store a lot of objects and the latter is correct so it would be beneficial to separate the data and have pure data objects and one data handler code.
Posted 21-Nov-11 20:27pm
Mehdi Gholam222.2K

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Methods are stored once - you don't change them so they are effectively static objects: only one instance per class.
  Permalink  
Comments
Mehdi Gholam at 22-Nov-11 3:26am
   
Does this mean that the internal data portions of the class are stored apart from the method definitions for that class?
OriginalGriff at 22-Nov-11 3:39am
   
Yes - the code portions are not stored on the heap at all - they are in a totally different memory area.
Mehdi Gholam at 22-Nov-11 3:46am
   
Ah, but how many copies 1 or as many as the objects created?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Shai Vashdi 440
1 Sergey Alexandrovich Kryukov 221
2 OriginalGriff 183
3 Tadit Dash 160
4 Guruprasad.K.Basavaraju 125
0 Sergey Alexandrovich Kryukov 9,255
1 OriginalGriff 5,433
2 Peter Leow 4,100
3 Maciej Los 3,540
4 Abhinav S 3,333


Advertise | Privacy | Mobile
Web02 | 2.8.140415.2 | Last Updated 22 Nov 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid