memory,objects,class relationships

computeridiot007

computeridiot007

@computeridiot007-xUubel Oct 17, 2024
we know that memory is the basic requirement for all the things....even a variable occupy a memory in a space...my question is
we know that objects and methods are present inside the class in java ...my question is how the memory will be allocated....whether the memory will be shared or there will be separate allocation....if it is how it will be mapping objects into a memory
how it is done(with diagram) plz explain

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • gaurav.bhorkar

    gaurav.bhorkar

    @gauravbhorkar-Pf9kZD Feb 4, 2010

    Memory is generally allocated on stack and heap. It depends on your program and the compiler, is to how the memory allocation should be done.

    Remember, memory is not allocated by the compiler. The compiler just writes relative memory allocation table, the OS allocates memory at run-time.

    So, it also depends on your OS. Because it the stack is full, it will allocate memory at some other place.
  • computeridiot007

    computeridiot007

    @computeridiot007-xUubel Feb 4, 2010

    thanks for ur reply ...can u tell me on xp and windows 7 about this case and take turboc and devc++
  • gaurav.bhorkar

    gaurav.bhorkar

    @gauravbhorkar-Pf9kZD Feb 4, 2010

    For C and C++ languages, memory allocation is done on the stack unless you specify it.
    Memory allocated using malloc () and new is always on heap.

    In newer languages like C# or python you are forced to allocate big objects on heap and small objects on stack.

    You must be knowing how much memory is allocated for int in 16 bit and in 32 bit.