I want to dive deeper into internals of object creation and storing. Any guidance?
hey guys. I decided to deepen my knowledge about how objects are created and stored. so im reading
Java: The complete reference
and i found this piece of code
and i was wondering, how can i peek into the place where objects are stored? i want to get/dive deeper into internals but idk how. any help? thanks!5 Replies
⌛
This post has been reserved for your question.
Hey @bambyzas! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
Baeldung
Stack Memory and Heap Space in Java | Baeldung
Explore how Stack Memory and Heap Space works and when to use them for developing better Java programs.
Or what do you mean by "the place where objcts are stored"?
All non primitive types in Java are stored on the heap (there is an exception for a specific optimization in which it sometimes doesn't, but let's ignore that for now)
So that means everything that extends Object (this includes arrays, even arrays of primitive types), will be allocated on the heap
If you hold a reference to an object (in the little example above,
mybox
), that's an actual pointer, that's a value that lives on the stack💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.