Questions tagged [heap-memory]

The heap is process memory set aside for dynamic allocation.

A heap memory pool is a large pool of memory which satisfies memory requests by allocating portions from this pool, commonly called the heap or free store. At any given time, some parts of the heap are in use, while some are "free" (unused) and thus available for future allocations.

Examples:

  • Java objects reside in an area called the heap. The heap is created when the JVM starts up and may increase or decrease in size while the application runs.

  • In Sybase's Adaptive Server Enterprise, if you make a wide column or row change, the temporary buffer this task uses can be as large as 16K, which is too big to allocate from the stack. Adaptive Server dynamically allocates and frees memory during the task’s runtime.

Since the precise location of the allocation is not known in advance, the memory is accessed indirectly, usually through a pointer reference.

6547 questions
9302
votes
31 answers

What and where are the stack and heap?

What are the stack and heap? Where are they located physically in a computer's memory? To what extent are they controlled by the OS or language run-time? What is their scope? What determines their sizes? What makes one faster?
982
votes
19 answers

Why should C++ programmers minimize use of 'new'?

I stumbled upon Stack Overflow question Memory leak with std::string when using std::list, and one of the comments says this: Stop using new so much. I can't see any reason you used new anywhere you did. You can create objects by value…
bitgarden
  • 10,461
  • 3
  • 18
  • 25
948
votes
22 answers

Error java.lang.OutOfMemoryError: GC overhead limit exceeded

I get this error message as I execute my JUnit tests: java.lang.OutOfMemoryError: GC overhead limit exceeded I know what an OutOfMemoryError is, but what does GC overhead limit mean? How can I solve this?
Mnementh
  • 50,487
  • 48
  • 148
  • 202
562
votes
31 answers

How to deal with "java.lang.OutOfMemoryError: Java heap space" error?

I am writing a client-side Swing application (graphical font designer) on Java 5. Recently, I am running into java.lang.OutOfMemoryError: Java heap space error because I am not being conservative on memory usage. The user can open unlimited number…
Eugene Yokota
  • 94,654
  • 45
  • 215
  • 319
544
votes
24 answers

Which is faster: Stack allocation or Heap allocation

This question may sound fairly elementary, but this is a debate I had with another developer I work with. I was taking care to stack allocate things where I could, instead of heap allocating them. He was talking to me and watching over my shoulder…
Adam
  • 25,966
  • 23
  • 76
  • 87
531
votes
34 answers

Node.js heap out of memory

Today I ran my script for filesystem indexing to refresh RAID files index and after 4h it crashed with following error: [md5:] 241613/241627 97.5% [md5:] 241614/241627 97.5% [md5:] 241625/241627 98.1% Creating missing list... (79570 files…
Lapsio
  • 6,384
  • 4
  • 20
  • 26
525
votes
10 answers

How is the default max Java heap size determined?

If I omit the -Xmxn option from the Java command line then a default value will be used. According to Java documentation "the default value is chosen at runtime based on system configuration" What system configuration settings influence the…
Richard Dorman
  • 23,170
  • 16
  • 45
  • 49
356
votes
3 answers

Java heap terminology: young, old and permanent generations?

I'm trying to understand What the concepts of young, old and permanent generations are in the Java heap terminology, and more specifically the interactions between the three generations. My questions are: What is the young generation? What is the…
knorv
  • 49,059
  • 74
  • 210
  • 294
331
votes
13 answers

Increase heap size in Java

I am working on a Windows 2003 server (64-bit) with 8 GB RAM. How can I increase the heap memory maximum? I am using the -Xmx1500m flag to increase the heap size to 1500 Mb. Can I increase the heap memory to 75% of physical memory (6 GB Heap)?
Sunil
  • 4,133
  • 6
  • 23
  • 21
323
votes
16 answers

java.lang.OutOfMemoryError: GC overhead limit exceeded

I am getting this error in a program that creates several (hundreds of thousands) HashMap objects with a few (15-20) text entries each. These Strings have all to be collected (without breaking up into smaller amounts) before being submitted to a…
PNS
  • 19,295
  • 32
  • 96
  • 143
322
votes
27 answers

Could not reserve enough space for object heap

I am getting the following exception repeatedly each time I try to run the program. Error occurred during initialization of VM Could not reserve enough space for object heap Could not create the Java virtual machine. I tried to increase my virtual…
Narendra
  • 5,635
  • 10
  • 42
  • 54
267
votes
7 answers

How do I analyze a .hprof file?

I have a production server running with the following flag: -XX:+HeapDumpOnOutOfMemoryError Last night it generated a java-38942.hprof file when our server encountered a heap error. It turns out that the developers of the system knew of the flag but…
Nick Stinemates
  • 41,511
  • 21
  • 59
  • 60
260
votes
12 answers

What is memory fragmentation?

I've heard the term "memory fragmentation" used a few times in the context of C++ dynamic memory allocation. I've found some questions about how to deal with memory fragmentation, but can't find a direct question that deals with it itself. …
AshleysBrain
  • 22,335
  • 15
  • 88
  • 124
243
votes
6 answers

Stack vs heap allocation of structs in Go, and how they relate to garbage collection

I'm experiencing a bit of cognitive dissonance between C-style stack-based programming, where automatic variables live on the stack and allocated memory lives on the heap, and Python-style stack-based-programming, where the only thing that lives on…
Joe
  • 46,419
  • 33
  • 155
  • 245
228
votes
18 answers

How can I find Java heap size and memory used (Linux)?

How can I check heap size (and used memory) of a Java application on Linux through the command line? I have tried through jmap. But it gives information about internal memory areas, like Eden, PermGen, etc., which is not useful to me. I am looking…
Jasper
  • 8,440
  • 31
  • 92
  • 133
1
2 3
99 100