About 278,000 results
Open links in new tab
  1. When is memory space allocated to a variable? - Stack Overflow

    The variable is allocated when the structure containing it is allocated. For a local variable in a method this is (with some caveats) when the method is invoked. For a static variable this is when the class is "initialized" (which happens some time after it's loaded and before it's first used).

  2. What is the actual memory place for static variables?

    Feb 26, 2021 · Out of five memory areas that JVM uses, the static fields are allocated memory in Class Area (part of PremGen) when the class is loaded by the Application class loader during prepare and loading phase.

  3. memory allocation for variables in java - Stack Overflow

    It depends. If notUsedVariable is a local variable, the assignment will probably be ignored by the JIT compiler (but we are talking about one register read/write, i.e. sub-nanosecond stuff on modern desktop processors). As demonstrated by MattBall the …

  4. Understanding storage of static methods and static variables in Java

    Jul 26, 2024 · Static methods and variables in Java are crucial for managing shared data across instances, stored in PermGen (Java 5 and 6) or MetaSpace (Java 8 and later). Understanding these memory management aspects ensures efficient Java application performance.The transition from PermGen to Metaspace in Java 8 has significantly improved the way the JVM ...

  5. Java Memory Management - GeeksforGeeks

    Jan 2, 2025 · Java memory management is a fundamental concept that involves the automatic allocation and deallocation of objects, managed by the Java Virtual Machine (JVM). The JVM uses a garbage collector to automatically remove unused objects, freeing up memory in the background. This eliminates the need for developers to manually handle memory management.

  6. Memory Allocation with Java

    Mar 13, 2023 · Static memory is the stack memory in Java. The stack memory is used to allocate space from local variables, and methods invocations in the LIFO (Last-in Last-out) style.

  7. Memory Allocation in Java: How It Works and Best Practices

    6 days ago · Memory allocation in Java refers to the process of reserving space for your program’s data, such as variables or objects, so they can function correctly. The Java Virtual Machine (JVM) automatically assigns memory whenever you create an object and clears it up when that object no longer serves any purpose.

  8. Stack Memory and Heap Space in Java - Baeldung

    Jul 1, 2024 · Stack Memory in Java is used for static memory allocation and the execution of a thread. It contains primitive values that are specific to a method and references to objects referred from the method that are in a heap. Access to this memory is in Last-In-First-Out (LIFO) order.

  9. Memory Management in Java - Guru99

    Nov 26, 2024 · Memory Allocation in Java is the process in which the virtual memory sections are set aside in a program for storing the variables and instances of structures and classes. However, the memory isn’t allocated to an object at declaration but only a reference is created.

  10. Memory Allocation in Java: Best Practices and Strategies

    Sep 27, 2023 · In this comprehensive guide, we will delve deep into memory allocation in Java, exploring its core concepts, common challenges, and best practices for optimization.

  11. Some results have been removed
Refresh