File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question of memory consumption for variable

 
avseq anthoy
Ranch Hand
Posts: 106
  • 0
  • 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
 
Ravishanker kumar
Ranch Hand
Posts: 53
  • 0
  • 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.
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • 0
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic