Packages & Imports
A Package groups related classes to prevent naming conflicts.
package com.visualizer;\nimport java.util.List;Select a language and click ⚡ to compile.
Compile to start visualizing
Step through memory state line by line
In-depth guide to memory management, core constructs, and how the runtime handles your code.
A Package groups related classes to prevent naming conflicts.
package com.visualizer;\nimport java.util.List;A Class is a blueprint. An Object is a runtime instance allocated on the Heap.
class Car { String color; }\nCar myCar = new Car(); // ref on Stack, object on HeapA Constructor initialises a new object via the new keyword.
Primitives store values on the Stack. Reference types store a pointer to the Heap.
Official docs ↗Each method call pushes a new frame on the Call Stack. Variables die when the frame is popped.
Official docs ↗A LIFO structure. Every method invocation pushes a frame storing locals and the return address.
JVM spec ↗Shared, dynamic memory where all objects and arrays live. Access is via stack references.
JVM spec ↗When an object has zero reachable references, the GC marks it for deletion automatically.
GC Guide ↗Java passes a copy of the reference value. The method can mutate heap data but cannot reassign the caller's variable.
Official docs ↗Python is dynamically typed. Variables are names pointing to heap objects.
x = 42\nname = "Ada"\nx = 3.14 # x now points to a new floatPython uses LEGB scope: Local → Enclosing → Global → Built-in.
Execution Model ↗Everything in Python is an object. __init__ initialises instance attributes; self is explicit.
list — ordered. dict — key-value. set — unique. tuple — immutable.
Sequence Types ↗Python maintains a stack of frame objects. Deep recursion raises RecursionError.
All Python objects live on the heap. CPython uses pooled allocators for small objects.
Memory Management ↗CPython uses reference counting. A cyclic GC handles reference cycles.
gc module ↗Python passes the reference value. Mutating a mutable argument affects the original.
FAQ ↗var is function-scoped and hoisted. let and const are block-scoped. Prefer const.
A closure retains access to its enclosing lexical scope even after that scope returns.
MDN ↗JavaScript is prototype-based. class is sugar over prototype chains.
JS is single-threaded. The Event Loop moves async callbacks to the stack only when it's empty.
MDN ↗var declarations are hoisted. let/const enter the temporal dead zone until initialised.
Objects and closures are allocated on the V8 Heap, split into young and old generations.
V8 blog ↗V8 uses mark-and-sweep with generational collection. Unreachable objects are collected.
MDN ↗Primitives copied by value. Objects by reference — two variables can share one heap object.
MDN ↗C++ is statically typed. Core types: int, double, bool, char. Use auto for inference.
A pointer (T*) stores an address. A reference (T&) is an alias — no null, no reseating.
new allocates on the heap. delete frees it. Modern C++ prefers smart pointers over raw pointers.
The Stack is automatic — locals destroyed deterministically. The Heap is manual or RAII managed.
Storage duration ↗struct members are public by default; class members are private.
Resource Acquisition Is Initialisation — acquire in constructor, release in destructor. Guaranteed cleanup.
cppreference ↗unique_ptr — sole ownership. shared_ptr — shared ref-count. weak_ptr — non-owning.
auto p = std::make_unique<int>(42);\nauto s = std::make_shared<Dog>("Rex");Templates enable generic programming. The compiler instantiates a concrete version per type used.
template<typename T>\nT add(T a, T b) { return a + b; }