CrazyEngineers
  • So What I understood is that-

    Classname object=new Classname();

    Here an object will be created in heap and the reference to it will be stored in stack.After we close the program the reference is lost from stack but object still resides in heap(although the memory now is free for reallocation).

    Is it correct?Because If it is, then only I will ask my further query.😁
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Nayan Goenka

    MemberMay 18, 2013

    Yes its correct, Stack is for temporary data members, heap is for permanent ones. Whats the query. Also these links might be useful to you. do read them. they might clear your doubts.

    #-Link-Snipped-#
    #-Link-Snipped-#
    #-Link-Snipped-#
    Are you sure? This action cannot be undone.
    Cancel
  • Whats In Name

    MemberMay 18, 2013

    So If we somehow acknowledge the value of the reference variable which actually has a address then after closing the program can we point to the same address again(manually)?
    Are you sure? This action cannot be undone.
    Cancel
  • Nayan Goenka

    MemberMay 18, 2013

    Whenever you make a program you allocate some memory to it for its functioning. It does not mean that you will fool around the entire hard disk with hex dumps to certain locations and try to access them. the point is, stacks are references to data objects in heaps, but in the memory location of the heap, the data is stored along with pointer to its referrer. your program knows where to look for it when its compiled but if you provide hex dumps in your program it MAY show error and treat as garbage value. You may use it in one instance but what about when the some other program or the same one as your previous one traverses the memory location? the whole new program will get corrupt due to unsanctioned usage of memory location and overlapping of pointers. Also it is not recommended to do so as the program will not respond as it is intended to. This type of coding is done when working on Emulators or making your own BootShell where there is an entire concept related to memory programming. It is not compatible or either recommended for your Java Apps or functions.
    Are you sure? This action cannot be undone.
    Cancel
  • Whats In Name

    MemberMay 18, 2013

    It was very informative.Thanks!

    .the data is stored along with pointer to its referrer. your program knows where to look for it when its compiled but if you provide hex dumps in your program it MAY show error and treat as garbage value.
    Doesn't that hex dump equals the reference which is stored along with the data?

    Sorry,If it sounds like an annoying query.😕
    Are you sure? This action cannot be undone.
    Cancel
  • Nayan Goenka

    MemberMay 18, 2013

    It does but in an overall view that is not the only program running on your computer, there are hundreds more, also include the compiler compiling for you, you can never predict. The case maybe different if you get into Debuggers and find out which program is running on which memory, which traversing agents are active and which exact memory space is isolated (which is none 😛), you cannot manage to give a direct call to data on a specific memory address.
    Are you sure? This action cannot be undone.
    Cancel
  • Whats In Name

    MemberMay 18, 2013

    Thanks a lot! I am glad I got the answer😀
    Are you sure? This action cannot be undone.
    Cancel
  • Nayan Goenka

    MemberMay 18, 2013

    Thanks, happy to help 😁
    Are you sure? This action cannot be undone.
    Cancel
  • rahul69

    MemberMay 21, 2013

    Nayan Goenka
    Whenever you make a program you allocate some memory to it for its functioning. It does not mean that you will fool around the entire hard disk with hex dumps to certain locations and try to access them. the point is, stacks are references to data objects in heaps, but in the memory location of the heap, the data is stored along with pointer to its referrer. your program knows where to look for it when its compiled but if you provide hex dumps in your program it MAY show error and treat as garbage value. You may use it in one instance but what about when the some other program or the same one as your previous one traverses the memory location? the whole new program will get corrupt due to unsanctioned usage of memory location and overlapping of pointers. Also it is not recommended to do so as the program will not respond as it is intended to. This type of coding is done when working on Emulators or making your own BootShell where there is an entire concept related to memory programming. It is not compatible or either recommended for your Java Apps or functions.
    Interesting discussion!😀 #-Link-Snipped-# correct me if I am wrong but I think by the time that memory of object will be accessed by using hex dumps, it would had already been cleared by Garbage Collector, so there would not be anything useful there to be accessed.
    Are you sure? This action cannot be undone.
    Cancel
  • Nayan Goenka

    MemberMay 21, 2013

    Garbage Collector is nothing else but another program, instead of using the specific name, i generalized it by other program 😀.
    Are you sure? This action cannot be undone.
    Cancel
  • Whats In Name

    MemberMay 21, 2013

    Computer memory!Interesting it is.😀
    Are you sure? This action cannot be undone.
    Cancel
  • Nayan Goenka

    MemberMay 21, 2013

    Sure it seems interesting, Just try and use a single debugger or memory mapper, you will understand. It was a nightmare for me when i had to use that, trust me, it tests all your patience. 😛
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register