heap

Is the size of an object needed for creating object on heap?

When compiler need to know the size of a C (class) object: For example, when allocating a C on the stack or as a directly-held member of another type From C++ Coding Standards: 101 Rules, Guidelines, and Best Practices Does that mean for a heap allocated object, size is not necessary? Class C;//just forward declaration C * o...

A min-heap with better than O(logn) increase key?

I'm using a priority queue that initially bases the priority of its elements on a heuristic. As elements are dequeued the heuristic is updated and elements currently in the queue may have their keys increased. I know there are heaps (Fibonacci heaps specifically) that have amortized O(1) decrease key operations, but are there any heap ...

jmap not working on windows server 2003

jmap works fine for me on XP. But when I try to execute the command, it throws and error Not enough storage available to process. I used the following command jmap -dump:format=b,file=heap1.bin . Note that tomcat is running as a service on windows server. I tried the same on windows xp and no problems there. Any ideas?? Thanks ...

How to debug heap corruption errors?

I am debugging a (native) multi-threaded C++ application under VS2008. 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 won't always crash the application right away, although it is likely to crash short after. The big probl...

Can I write a C application without using the heap?

I'm experiencing what appears to be a stack/heap collision in an embedded environment (see this question for some background). I'd like to try rewriting the code so that it doesn't allocate memory on the heap. Can I write an application without using the heap in C? For example, how would I use the stack only if I have a need for dynami...

Creating arrays on the heap and addressing them with pointers

Hi, I'm having trouble understanding the following bit of code that I was hoping would create an array on the heap and fill it with the characters 9 down to 0 (I know I could just index the array like a normal stack array with [] notation to do this but I'm doing it this way to try to understand pointers in more depth): int *ptrHeapArra...

Need help with my heap sort

I'm kind of stuck with my heap sort here in php: <?php function heapSort($a, $count){ $a = heapify($a, $count); $end = $count - 1; while ($end > 0){ $temp = $a[$end]; $a[$end] = $a[0] ; $a[0]= $temp; $end = $end - 1; siftDown($a, 0, $end); } return $a; } function hea...

manipulation of Vectors created with new

Can anyone help with this... vector<unsigned int> *vVec = new vector<unsigned int>; vVec .reserve(frankReservedSpace); start = std::clock(); for(int f=0; f<sizeOfvec; f++) { //Populate the newly created vector on the heap vVec .push_back(pArray[f]); } I'm getting: error C2228: left...

Does Python's heapify() not play well with list comprehension and slicing?

I found an interesting bug in a program that I implemented somewhat lazily, and wondered if I'm comprehending it correctly. The short version is that Python's heapq implementation doesn't actually order a list, it merely groks the list in a heap-centric way. Specifically, I was expecting heapify() to result in an ordered list that facili...

How can I configure Spring to save as much memory as possible?

We're deploying an application on a semi-embedded device that has memory constraints. Looking to save whatever we can we are analysing heap dumps of the app and attacking the biggest consumers. We use Spring 2.5 together with Spring DM 1.1 and we notice that some of our bundles with more complex Spring contexts are using up quite a bit...

Is it on the Stack or Heap?

I have some C code that is something of a puzzle. For a reason to do with this code, I'm wondering how I can tell if a struct object is ending up on the heap or stack? The objects are not being created with malloc or calloc. They start their life in the form of an array. For the purposes of this post, I'm going to call the struct Emp. ...

Java Refuses to Start - Could not reserve enough space for object heap

Background We have a pool of aproximately 20 linux blades. Some are running Suse, some are running Redhat. ALL share NAS space which contains the following 3 folders: /NAS/app/java - a symlink that points to an installation of a Java JDK. Currently version 1.5.0_10 /NAS/app/lib - a symlink that points to a version of our applicatio...

What is the Maximum Java Heap Space for SuSE Linux

This question is related to Java Refuses To Start - Could Not Resrve Enough Space for Object Heap and should be easy enough to figure out. However; my searches haven't yielded anything useful. Essentially we have 2 32 bit OS's (RedHat & SuSE) on different machines with the same hardware. Both use the same JVM both executing the same c...

Why not use pointers for everything in C++?

Suppose that I define some class: class Pixel { public: Pixel(){ x=0; y=0;}; int x; int y; } Then write some code using it. Why would I do the following? Pixel p; p.x = 2; p.y = 5; Coming from a Java world I always write: Pixel* p = new Pixel(); p->x = 2; p->y = 5; They basically do the same thing, right? O...

Java Object Method Stack Frame Parameters

So in java, say you have a non-static method 'bar()' in an class 'Foo'. class Foo { private int m_answer; public Foo() { m_answer = -1; } public void bar(int newAnswer) { m_answer = newAnswer; } } Say then that you call this method like so: Foo myFoo = new Foo(); myFoo.bar(42); Now the...

What do those strange class names in a java heap dump mean?

I'm trying to track down a memory leak in a java process, using jmap and jhat. Every time I do this I see those weird notation for specific object types, like [S for string arrays and [C for Character arrays. I never remember what means what, and it's very hard to google this stuff. (EDIT: to prove my point, it turns out that [S is arra...

Is it possible to dynamically change maximum java heap size?

I know you can set max heap size at startup using -Xmx but is it possible to change it dynamically during runtime? Is there any tool or (undocumented) api which will allow me to do that? ...

Uninitialised values of heap and stack space

Why is the heap space always set to zero?? Why is stack space similarly not set to zero?? ...

HeapCreate vs GetProcessHeap

Hi I'm new to using Heap Allocation in C++. I'm tryin to understand the scenario that will force someone to create a private heap instead of using the Process Heap. Isn't Process Heap generally enough for most of the cases? Thanks --Ashish ...

(C#) 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 array. As they are value types, I'd guess they'd have to be boxed, as I can, for example, pas...