Results 1 to 4 of 4
  1. #1
    kishan's Avatar
    kishan is offline Member
    Join Date
    Apr 2009
    Posts
    57
    Rep Power
    0

    Default Memory Allocation

    Hi folks,
    see this ex:

    int v=5;
    v=v+10;

    then what will do the compiler before the output come as 15.
    Please explain me technically.

  2. #2
    mrmatt1111's Avatar
    mrmatt1111 is offline Senior Member
    Join Date
    Aug 2009
    Location
    San Jose, CA, USA
    Posts
    320
    Rep Power
    5

    Default

    The compiler will turn your code into bytecode.
    My Hobby Project: LegacyClone

  3. #3
    kishan's Avatar
    kishan is offline Member
    Join Date
    Apr 2009
    Posts
    57
    Rep Power
    0

    Default

    thanks for ur reply.....
    but my question is how the memory allocation of variable "v" will be, from begining of code to the ending during execution?

  4. #4
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    6

    Default

    First off, the compiler does not output the result of the statements. It converts the statements to bytecode as mentioned by kishan. Memory allocation is done by the JVM at run-time. Before runtime, no memory is allocated at all.
    During runtime, the JVM will set aside 32 bits of space to store v, then assign a value to that space (5), replace that value with the sum of v and 5. result of v+5 is stored in a temporary location before overwriting v itself.

Similar Threads

  1. Resource management allocation
    By jyothi.priyanka in forum New To Java
    Replies: 0
    Last Post: 04-04-2009, 01:25 PM
  2. Replies: 2
    Last Post: 08-21-2008, 07:33 PM
  3. Out of memory
    By mew in forum New To Java
    Replies: 1
    Last Post: 01-20-2008, 08:55 AM
  4. Memory
    By mew in forum CLDC and MIDP
    Replies: 0
    Last Post: 12-28-2007, 11:02 AM
  5. How Can I get free memory ?
    By sathish_2111 in forum Networking
    Replies: 2
    Last Post: 07-19-2007, 04:29 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
  •