"Claire" <as*******@ntlworld.com> a écrit dans le message de news:
OJ**************@TK2MSFTNGP15.phx.gbl...
If I need to create thousands of objects of the same type, is it more
economical (memory wise) to use static member functions where possible?
How about virtual ones?
All code for member functions only exists once in memory, no matter how many
instances are created. Static member functions need to have any non-static
data passed into them. Virtual methods also exist only once in memory; the
only difference being that their addresses also appear in the VMT.
Unless you are planning on doing a vast in-memory calculation which requires
all objects to be present, I would sincerely doubt whether it is a good idea
to load so many objects at the same time. Can these objects not be persisted
in a database or other mechanism and paged in as required ?
If the objects are for browsing only, then you really need to 'persuade'
users to supply at least a partial-match search criteria to reduce the
returned set to a more managable size.
Joanna
--
Joanna Carter
Consultant Software Engineer