• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

Question of memory consumption for variable  RSS feed

 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all
I have two variable as below


I want to use a object to encapsulae these variables.


If I use a object to to encapsulae these variables , it will be more memory consumption than the original way?





I have to refactor a complicated code recently, and I want to encapsulate some complex structure and variables into a object.
But it will create many object in tthe code.
ex:


So I want to know if I save some information in a object , does it will be more memory consumption than before?
tks
 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to my understanding, yes...there will be little more memory consumed by program in second case, because you are creating one additional object of class Person. But that is fine to make program object oriented.
 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course the Person version has more overhead. Think about it, you create an object of type Person and String objects, as opposed to only String objects. But the difference in memory footprint and performance is miniscule and above all the whole concept of OOP is making your architecture object oriented.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!