heap

why would I forbid allocation in the heap?

I recently read a lot about "preventing heap allocation for a class" (see this question). I was able to understand "how", but now I can't figure out "why" someone would like to do that. I guess there must be legitimate reasons for this, but I just can't figure them out. In short: "Why may I want to forbid users from creating objects o...

gcc, c++: static string member variarible causes heap corruption/segmentation fault

I have a big application that uses the dynamically loaded libraries. At the end of program while terminating it either segfaults or spits a message "glibc detected corrupted double-linked list". Looking at the valgrind output I think this is what the case is: let say we have three files: utilities.c - compiled with -fPIC and used...

Address of Stack and Heap in C++

Correction: I messed up with the concept of pointer address and the address the pointer points to, so the following code has been modified. And now it prints out what I want, variable a, c, i, j, k, p are on the stack, and variable b,d are on the heap. Static and global variables are on another segment. Thanks a lot for all of you! ...

Java: Change object reference on the heap?

Wondering if there is a way to change the object on the heap that other objects are referencing. What I am specifically trying to do is manage my transient configuration. What I am doing is loading "bound" configuration from JAXB or JPA. I have a manager which maintains some threads to check if those config stores change. If they do,...

HEAP_NO_SERIALIZE flag.

When I called the HeapCreate function in the preceding code sample, I used the HEAP_NO_SERIALIZE flag because the remainder of the sample code is not multithread-safe. Jeffrey Richter wrote the sentence in his book(Windows via C/C++) But it's weird. If the codes are not multithread-safe he didn't have to use the flag. Is it a bug?...

How to programmatically get the address of the heap on Linux

I can get the address of the end of the heap with sbrk(0), but is there any way to programmatically get the address of the start of the heap, other than by parsing the contents of /proc/self/maps? ...

JVM fails to allocate XMS under Suse SLES10 X64 running on VMWare ESX

I am trying to allocate ram with xms = xmx on a sles10 x64 running under VMware. When stopping the JVM the following error is thrown: Java HotSpot(TM) 64-Bit Server VM warning: Failed to reserve shared memory (errno = 12). The RAM of the VM is 8 GB and they are reserved. The VM sees 8GB and it can be allocated during runtime via the...

C# Generics: Inserting T as the where T : IComparable<T> interface conflict

This is a challenge for the C# generics / design patterns masters. I'm trying to implement a generic heap, and then a priority queue that uses the heap. My heap's signature is: class Heap<TKey, TValue> where TKey : IComparable<TKey> My priority queue class is: public delegate IComparable<T> Evaluator<T>(T item); class PriorityQueu...

Creating object in the heap

Hello, I'm using boost::ptree for parsing fils. The problem is that I can't create the object in the heap. All samples is only for stack. #include <boost/property_tree/ptree.hpp> ptree *tree_handle; read_info("path", tree_handle); I need this because the code is in a function and I have to return the ptree-object from it. Errors: ‘b...

unable to set more than 544mb heap size in eclipse

i'm confused, i have 4gb ram machine - 64bit win7 if i try to set -Xmx more than 544m in eclipse.ini i get the error "Could not create the Jave virtual machine". i use 32bit eclipse helios and 32bit vm ...

Reasons why my Android App would crash on my phone consistently, but not on my emulator

I have an app that uses quite a few graphics in it. When I open and close my app repeatedly on my emulator (1.5 - 2.2) it runs fine and by checking the heap I can see everything is being cleaned and gc'd properly. However, when I run my app on an HTC Aria phone (2.1) the app crashes every time I try to re-open it. When I look at the h...

How can i access heap memory beside using malloc?

Is there a way that you can assign memory from heap without a call to malloc? Can the following call be affective for it? void* loc = (void*) &heap[end_of_heap]; ...

Does the Java primitives go on the Stack or the Heap?

I just know that the non-primitives (the objects) go on the heap, and methods go on the stack, but what about the primitive variables? --update Based on the answers, I could say the heap can have a new stack and heap for a given object? Given that the object will have primitive and reference variables..? ...

Java's enum... Where are they created?

Hi all, Since enum in C# are on the stack, I was wondering where enum, in Java, where created. On the stack? On the heap? In some mysterious other place? Enumeration in C# are more primitive than those in Java, this might explain why they are created on the stack... Where are they? I can't find them! Thanks ...

How do I allow the user to easily choose how much memory to allocate in a Java Swing app?

We have a Swing app that processes relatively large amounts of data. For instance we currently process csv files with millions of rows of data. For the reasons of performance and simplicity we just keep all of the data in memory. However different users will have different amounts of data they need to process as well as different amou...

How efficient is it to return very large data in F#?

Hello F# folks, Suppose we have a Matrix class in F# and you overload the (+) operator. Then, we will have something like this: type Matrix(n : int, m : int) = ... static member (+) (A : Matrix, B : Matrix) = let res = new Matrix(A.Dim1, A.Dim2) // suppose A and B have the same dimension ... // compute here th...

java out of memory error when executing a swing client

Hi, My executable swing client throws out of memory exception when executed from a remote machine. However, executing the client from command line (increasing the heap space) using the following command works. java -XMx128m -Xms128m -jar myclient.jar I do not want the remote users use my client through command line as shown above. So,...

Heap corruption during SetClipboardData()

I'm not sure what is the root cause for getting such error(Heap Corruption) from the below code. When i step through the program, the TCHAR value is properly allocated and copied to the clipboard data. However, it crash when it proceed to SetClipboardData(...). Can any guru help to spot the error? Thanks in advance. Error Dialog: ...

Stack and heap in c sharp

Possible Duplicate: Why are structs stored on the stack while classes get stored on the heap(.NET)? Can anyone tell me that how the allocation of memory is done that which object is to be stored in stack and which to be in heap portion of the memory? ...

What is the equivalent for heapq of Python in Java?

I would like to know if there is any api available for Java which is just like heapq in Python. ...