Results 1 to 9 of 9

Thread: Object memory

  1. #1
    mohitchouhan is offline Member
    Join Date
    Feb 2011
    Posts
    9
    Rep Power
    0

    Default Object memory

    Does every object has its own copies of non static methods in memory??

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by mohitchouhan View Post
    Does every object has its own copies of non static methods in memory??
    No .

  3. #3
    mohitchouhan is offline Member
    Join Date
    Feb 2011
    Posts
    9
    Rep Power
    0

    Default

    Can u give me some more explanation sir i am just a newbie:(

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by mohitchouhan View Post
    Can u give me some more explanation sir i am just a newbie:(
    What more detail do you wish? You asked a yes/no question, and the answer is no.

  5. #5
    mohitchouhan is offline Member
    Join Date
    Feb 2011
    Posts
    9
    Rep Power
    0

    Default

    I mean if we have created 10 objects of any class then methods(whether static or non static) will have comman copy in memory and all objects would share them .....am i right? :(

  6. #6
    imorio is offline Senior Member
    Join Date
    Aug 2010
    Posts
    127
    Rep Power
    0

    Default

    This is a link to a course by stanford. It is called cs106a. Follow it completly and do the assignments. Then follow the course cs106b, also on youtube. Then cs107. About halfway through cs107 you will understand exactly how objects work under the hood. Good luck!

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by mohitchouhan View Post
    I mean if we have created 10 objects of any class then methods(whether static or non static) will have comman copy in memory and all objects would share them .....am i right? :(
    Yes, all the objects will share the same method byte code. When methods are called though, parameters and local variables will be pushed onto the stack, so memory will be temporarily used during a method's run.

    For more on methods and memory, check Google. One hit it gave me was this:

    memory-allocation-methods-java

  8. #8
    mohitchouhan is offline Member
    Join Date
    Feb 2011
    Posts
    9
    Rep Power
    0

    Default

    @imorio Thanks sir...I wish this will help me...:)

  9. #9
    NRitH is offline Senior Member
    Join Date
    Feb 2011
    Posts
    118
    Rep Power
    0

    Default

    If you're a newbie, why on earth do you need to know whether objects of the same class share a single method copy in memory?

Similar Threads

  1. Replies: 1
    Last Post: 02-02-2011, 07:11 PM
  2. object stack memory id apeears instead of object itself
    By Embercloud in forum New To Java
    Replies: 7
    Last Post: 01-02-2011, 06:06 PM
  3. Replies: 2
    Last Post: 08-21-2008, 08:33 PM
  4. Object creation and memory issues
    By bugger in forum New To Java
    Replies: 11
    Last Post: 11-29-2007, 01:56 PM
  5. removing an object from memory
    By ravian in forum New To Java
    Replies: 1
    Last Post: 11-12-2007, 10:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •