heap

What's the relationship between "a" heap and "the" heap?

A heap is a tree data structure where higher levels of the tree always contain greater (or lesser, if it's set up that way) values than lower levels. "The" heap is a bunch of free RAM that a program has available for dynamic allocation. They're both called "heap," but what does the one have to do with the other? ...

Setting JVM heap size at runtime

Is there a way to set heap size from a running Java program? ...

Linking Two Multi-Dimensional arrays using pointers

I need to basically merge a Binary Heap, and Linear Probing Hashtable to make a "compound" data structure, which has the functionality of a heap, with the sorting power of a hashtable. What I need to do is create 2 2 dimension arrays for each data structure (Binary Heap, and Hash) then link them to each other with pointers so that when ...

Debug Visual C++ memory allocation problems

I'm debugging a software which crashes eventually with one of the following messages: 1. DAMAGE: after normal block (#24729280) at 0x00D710E0 2. Debug Assertion Failed Program: D:\Soft\Test.exe File: dbgheap.c Line: 1017 Expression: _BLOCK_TYPE_IS_VALID(phead->nBlockUse) This software is really old but changing it now is ...

How do I allocate a std::string on the stack using glibc's string implementation?

int main(void) { std::string foo("foo"); } My understanding is that the above code uses the default allocator to call new. So even though the std::string foo is allocated on the stack the internal buffer inside of foo is allocated on the heap. How can I create a string that is allocated entirely on the stack? ...

How do you make your Java application memory efficient?

How do you optimize the heap size usage of an application that has a lot (millions) of long-lived objects? (big cache, loading lots of records from a db) Use the right data type Avoid java.lang.String to represent other data types Avoid duplicated objects Use enums if the values are known in advance Use object pools String.intern() ...

CFINVOKE vs java.lang.OutOfMemoryError in ColdFusion

I'm having issues with ColdFusion's heap. Here's a little example application I'm experimenting with. I thought after cfinvoke calling the init method it destroys all variables local to the component. But apparently it's not the case. The application works as it is below but if I add a zero to the loop in index.cfm it breaks. What's stor...

Allocate more heap space to a Java jar

When you run a program through the command line, you can use java -Xms -Xmx to specify the heap sizes. If the program is going to be run by double clicking a .jar file, is there a way to use more heap than the standard? ...

Implementing a 4-heap using an array.

What kind of math do you use to traverse the 4-heap when using an array to store all the elements? Specifically, how do you find the index of a parent node to a specific leaf? Let's say I have the following array: 0|1|2|3|4|5|6|7|8|9|10|... etc. with the heap then constructed from that with 1 being the root, 2..5 its children, 6..9 2'...

When does a mutable state value freed from heap?

On F# WikiBook under Encapsulating Mutable State section, there is a following code snippet. > let incr = let counter = ref 0 fun () -> counter := !counter + 1 !counter;; val incr : (unit -> int) > incr();; val it : int = 1 > incr();; val it : int = 2 > incr();; val it : int = 3 At first, it seemed easy eno...

How do I Save the Heap (Dump to a File) in Eclipse?

Hi Guys! I'm getting this error when I run or debug my GA/AI from MyEclipse: Exception in thread "main" java.lang.OutOfMemoryError: Java heap space eclipse.ini looks like this: -showsplash com.genuitec.myeclipse.product --launcher.XXMaxPermSize 256m -vmargs -Xms128m -Xmx512m -Duser.language=en -XX:PermSize=128M -XX:MaxPermSize=256M...

Where Do malloc() / free() Store Allocated Sizes and Addresses?

Hi, where do malloc() and free() store the allocated addresses and their sizes (Linux GCC)? I've read that some implementations store them somewhere before the actual allocated memory, but I could not confirm that in my tests. The background, maybe someone has another tip for this: I'm experimenting a little bit with analyzing the heap...

How to ensure JVM starts with value of Xms

When I run a java program with the starting heap size of 3G (set by -Xms3072m VM argument), JVM doesn't start with that size. It start with 400m or so and then keeps on acquiring more memory as required. This is a serious problem for me. I know JVM is going to need the said amount after some time. And when JVM increases is its memory a...

What's the differences between VirtualAlloc and HeapAlloc?

There are lots of method to allocate memory in windows enviorment, such as VirtualAlloc/HeapAlloc/malloc/new. Thus , what's the difference among them? ...

Where is allocated variable reference, in stack or in the heap ?

Hi all members of stackoverflow, I have a question What happend when I declare a variable inside a method, for example. void myMethod() { Ship myShip = new Ship(); } Where is allocated myShip reference, in stack or in the heap ? I think in stack but I'm confused because I was reading in J2ME Game Programming book "Java classes ...

increase the java heap size permanently?

Is there a way that I can set the default heap size for the jvm on my own computer? I want to set it to 1g, because I'm always running custom programs that always hit the overage point in the default jvm size. I just dont want to have to remember to type -XmX1g everytime I run my java app from the command line... There has to be an ...

Overcoming heap overflow issues

After taking a single Computer Science course last semester, I've been attempting to improve my coding abilities by trying to solve problems from Project Euler. I know my method would work logically(it returns answers to the small scale problem almost instantly). However, it scales horribly. If anyone could help me develop a better appro...

allocating and freeing a char * in c++

Hey everyone, I am getting a heap corruption error I cannot figure out. char * c = (char *) malloc(1); // main loop _gcvt_s(c, 100, ball->get_X_Direction(), 10); if(pushFont(c, (SCREEN_WIDTH - 30), (SCREEN_HEIGHT - 40), message, screen, font, textColor) == false) { //return 1; // error rendering text. } // end main loop f...

Is there a heap class in C++ that supports changing the priority of elements other than the head?

I have a priority queue of events, but sometimes the event priorities change, so I'd like to maintain iterators from the event requesters into the heap. If the priority changes, I'd like the heap to be adjusted in log(n) time. I will always have exactly one iterator pointing to each element in the heap. ...

Deleting a heap then dereferencing a pointer to that memory

This is code from an exercise: #include <iostream> using namespace std; int main() { int n = 13; int* ip = new int(n + 3); int* ip2 = ip; cout << *ip << endl; delete ip; cout << *ip2 << endl; cout << ip << tab << ip2 << endl; } When the space allocated to the int on the heap is deleted, I thought that dere...