Results 1 to 7 of 7
  1. #1
    watsonsong is offline Member
    Join Date
    Sep 2012
    Posts
    2
    Rep Power
    0

    Question How the java vm protect it's memory?

    I am really curious about how java protect it's memory, and check the invalid memory access.
    I guess it can check each memory access, but I think it will slowdown the program speed significantly.
    Or it can emulate the memory translate and page system just like the MMU. But the mmu it hardware, this method also slowdown the program.
    Or it launch each java process as an os process, and using the os memory protection directly, which can directly work with the hardware MMU.

    I search many article but no one explain it. And I am not diving into the java vm source code, so the memory protection of java like a blackbox for me.

    Is there any great hackers can help me, explain the question?

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,578
    Rep Power
    25

    Default Re: How the java vm protect it's memory?

    There is no pointer manipulation in Java.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    watsonsong is offline Member
    Join Date
    Sep 2012
    Posts
    2
    Rep Power
    0

    Default Re: How the java vm protect it's memory?

    But on the java virtual machine level, this mean it need track all reference address and type, check the address valid each time access an memory?
    For example when i check a variable in an object: if(obj1.x == 1), it mean first check the reference obj1 is a valid address, and whether it's type is correct, so it has enough memory to access x variable. Isn't this operation is too slow? Or there is something more efficient way to check the obj valid?

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,578
    Rep Power
    25

    Default Re: How the java vm protect it's memory?

    I don't know how a java program can address memory outside what is given it by the JVM.
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,097
    Rep Power
    20

    Default Re: How the java vm protect it's memory?

    The JVM is a process on the OS.
    It's no different to any other app, as far as the OS is concerned.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  6. #6
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,662
    Blog Entries
    7
    Rep Power
    21

    Default Re: How the java vm protect it's memory?

    The JVM doesn't do much checking; it's the OS that generates bus errors (mis-aligned memory references) or segmentation violations (out-of-process space memory references). It's the compiler that did most of the work, i.e. it checks whether or not the code is correct; it can't check bounds references, nor down casts so that is the job of the JVM, as well as division by zero and then some. It's a delicate balance: the JVM 'trusts' the compiler and the compiler 'trusts' the JVM to be correct. On top of that the content of a class file is checked when loaded.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  7. #7
    noctarius is offline Member
    Join Date
    Jun 2012
    Location
    Remscheid, Germany
    Posts
    61
    Rep Power
    0

    Default Re: How the java vm protect it's memory?

    The Class Verifier checks the class at loading time for non breaking references (and some things more). In addition every array access is index checked and memory pointers are only available by using tricks like sun.misc.Unsafe (or equivalent classes).

Similar Threads

  1. Replies: 2
    Last Post: 08-20-2012, 06:38 PM
  2. Protect Jar File
    By patriotsfan in forum Advanced Java
    Replies: 1
    Last Post: 11-29-2011, 08:59 PM
  3. Need protect you MacBook?
    By bababoo in forum Reviews / Advertising
    Replies: 0
    Last Post: 01-12-2011, 04:36 PM
  4. how to protect java codes from being seen?
    By anthrax in forum Eclipse
    Replies: 5
    Last Post: 10-14-2009, 03:43 PM

Tags for this Thread

Posting Permissions

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