Questions tagged [heap]

A heap (data structure) is a tree that is ordered with respect to depth. Heap can also refer to process memory set aside for dynamic allocation.

In computer science, a heap is a specialized tree-based data structure that satisfies the heap property: If A is a parent node of B then key(A) is ordered with respect to key(B) with the same ordering applying across the heap. Either the keys of parent nodes are always greater than or equal to those of the children and the highest key is in the root node (this kind of heap is called max heap) or the keys of parent nodes are less than or equal to those of the children (min heap).

A heap memory pool is an internal memory pool created at start-up that tasks use to dynamically allocate memory as needed. This memory pool is used by tasks that requires a lot of memory from the stack, such as tasks that use wide columns.

For example, 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.

The heap memory pool dramatically reduces the predeclared stack size for each task, while also improving the efficiency of memory usage in the server. The heap memory the task uses is returned to the heap memory pool when the task is finished.

Microsoft describes a heap for their SQL Server 2008 R2 as a table without a clustered index. Heaps have one row in sys.partitions, with index_id = 0 for each partition used by the heap. By default, a heap has a single partition. When a heap has multiple partitions, each partition has a heap structure that contains the data for that specific partition. For example, if a heap has four partitions, there are four heap structures; one in each partition.

5348 questions
188
votes
17 answers

Command-line Tool to find Java Heap Size and Memory Used (Linux)?

Is there a Command-line Tool (Linux) to check Heap Size (and Used Memory) of a Java Application? I have tried through jmap. But it gives info. about internal memory areas like Eden/ PermGen etc., which is not useful to me. I am looking for…
Jasper
  • 7,524
  • 24
  • 87
  • 131
173
votes
5 answers

When vectors are allocated, do they use memory on the heap or the stack?

Are all of the following statements true? vector vect; //allocates vect on stack and each of the Type (using std::allocator) also will be on the stack vector *vect = new vector; //allocates vect on heap and each of the Type will…
Phelodas
  • 2,903
  • 5
  • 18
  • 30
171
votes
15 answers

How to debug heap corruption errors?

I am debugging a (native) multi-threaded C++ application under Visual Studio 2008. On seemingly random occasions, I get a "Windows has triggered a break point..." error with a note that this might be due to a corruption in the heap. These errors…
Beef
169
votes
9 answers

Stack, Static, and Heap in C++

I've searched, but I've not understood very well these three concepts. When do I have to use dynamic allocation (in the heap) and what's its real advantage? What are the problems of static and stack? Could I write an entire application without…
Hai
  • 4,454
  • 8
  • 27
  • 26
162
votes
6 answers

Difference between "on-heap" and "off-heap"

Ehcache talks about on-heap and off-heap memory. What is the difference? What JVM args are used to configure them?
Synesso
  • 34,066
  • 32
  • 124
  • 194
158
votes
1 answer

Difference between sampling and profiling in jVisualVM

VisualVM has two separate tabs for sampling and profiling. What is the difference between sampling and profiling in VisualVM?
Parag
  • 10,693
  • 15
  • 53
  • 74
148
votes
9 answers

Detect application heap size in Android

How do you programmatically detect the application heap size available to an Android app? I heard there's a function that does this in later versions of the SDK. In any case, I'm looking for solution that works for 1.5 and upwards.
hpique
  • 112,774
  • 126
  • 328
  • 461
140
votes
8 answers

Arrays, heap and stack and value types

int[] myIntegers; myIntegers = new int[100]; In the above code, is new int[100] generating the array on the heap? From what I've read on CLR via c#, the answer is yes. But what I can't understand, is what happens to the actual int's inside the…
devoured elysium
  • 90,453
  • 117
  • 313
  • 521
128
votes
40 answers

What does "zend_mm_heap corrupted" mean

All of the sudden I've been having problems with my application that I've never had before. I decided to check the Apache's error log, and I found an error message saying "zend_mm_heap corrupted". What does this mean. OS: Fedora Core 8 Apache:…
bkulyk
  • 1,644
  • 2
  • 12
  • 17
124
votes
10 answers

Proper stack and heap usage in C++?

I've been programming for a while but It's been mostly Java and C#. I've never actually had to manage memory on my own. I recently began programming in C++ and I'm a little confused as to when I should store things on the stack and when to store…
Alexander
  • 2,947
  • 6
  • 22
  • 17
121
votes
6 answers

How to give Jenkins more heap space when it´s started as a service under Windows?

I want to increase the available heap space for Jenkins. But as it is installed as a service I don´t know how to do it.
Deleted
  • 3,659
  • 6
  • 29
  • 49
99
votes
6 answers

When would I want to use a heap?

Besides the obvious answer of a Priority Queue, when would a heap be useful in my programming adventures?
Mithrax
  • 7,053
  • 17
  • 52
  • 58
96
votes
8 answers

Android Gradle Could not reserve enough space for object heap

I've installed Android Studio 1.1.0. I haven't done anything yet like start new Android application or import anything. Somehow it is trying to build something and it throws sync error. Error:Unable to start the daemon process. This problem might…
GummDev
  • 1,100
  • 1
  • 8
  • 13
89
votes
5 answers

Is a Java array of primitives stored in stack or heap?

I have an array declaration like this: int a[]; Here a is an array of primitive int type. Where is this array stored? Is it stored on heap or stack? This is a primitve type int, all primitive types are not stored on heap.
user241924
  • 4,100
  • 7
  • 25
  • 25
86
votes
8 answers

Memory allocation: Stack vs Heap?

I am getting confused with memory allocation basics between Stack vs Heap. As per the standard definition (things which everybody says), all Value Types will get allocated onto a Stack and Reference Types will go into the Heap. Now consider the…
Mrinal
  • 903
  • 1
  • 7
  • 6