heap

Stack vs. Heap in .NET

Hi all, In your actual programming experience, how did this knowledge of STACK and HEAP actually rescue you in real life? Any story from the trenches? Or is this concept good for filling up programming books and good for theory? ...

Can you extract the value of strings from an IBM PHD java heap dump?

I have a PHD format heap dump from an IBM jvm and I wish to examine the values of some strings. With the Sun JVM's binary hprof dumps this is possible, but I haven't been able to recover this information from an IBM dump. I've tried: Eclipse Memory Analyzer (0.8.0.200906170940) with IBM's DTFJ Portal Heap Dump Reader (1.3.0.2009032416...

What's the default heap size for IBM's J9VM?

I have IBM's J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3) installed. After getting an OOM, the size of the heap dump is 383MB. How much heap does the JVM have? The reason why I ask is that a 400MB heap dump seems a bit much for the default 64MB heap that I expect but I didn't specify any -Xm options. Does J9 use a different default heap siz...

Populating Heap (malloc) with a string array

hello, i'm trying to populate the heap with a string array, but the console gave me nothing when i compiled. I don't know what I did wrong... void spellCheck(char article[], char dictionary[]) { int i = 0; char* tempArticle; while ( article[i] != '\0'){ i++; } tempArticle = malloc(i); i=0; while (article...

Check Spelling program in C

hello everyone. I'm a beginner to C programming. I'm trying to learning how to code a spell checker that looks through all the words in a dictionary file, compare them with an article, print out all the words that do not exist in the dictionary file onto the console. Since I'm studying malloc in class, I've lowercased every word, removed...

How to detect and estimate heap fragmentation in my C++ program?

I'm developing a VC++ NT service that is meant to operate continuously for many months. It uses VC++ runtime heap intensively. Clearly heap fragmentation can at some point cause it malfunctioning (thinking it's out of memory). What tests can I run on my service to estimate the degree it is prone to heap fragmentation? ...

merge heaps algorithm

is there an efficient algorithm for merging 2 max-heaps (stored as an array)? ...

Array of objects on stack and heap

Consider the following code: class myarray { int i; public: myarray(int a) : i(a){ } } How can you create an array of objects of myarray on stack and how can you create an array of objects on heap??? ...

Creating a struct on the heap?

I've been instructed to write a model strdup by creating a String struct on the heap the holds a copy of the source. I think I have successfully coded the strdup, but I'm not sure if I've created a Struct on the heap... typedef struct String { int length; int capacity; unsigned check; char ptr[0]; } String; char* model...

C# - Objects allocated on heap

Hi, Whenever any new object is created, the object is created on heap. The memory allocated for each object has two additional fields 1) The type object pointer 2) sync block index. What exactly is the usage of these two fields. Can anybody shed light on this? Thanks, Justin Samuel. ...

Why do we need to typecast what malloc returns?

int length = strlen(src); char *structSpace = malloc(sizeof(String) + length + 1); String *string = (String*) structSpace; int *string = (int*) structSpace; *I created a struct called String ...

Checking values in Heap

I'm trying to check a in the heap with char* c = s - sizeof(unsigned); But it always returns gibberish to me. I'm wondering what did I do wrong... typedef struct String { int length; int capacity; unsigned check; char ptr[0]; } String; char* modelStrrealloc(char* myStruct, int new_capacity){ char* c = ...

Checking heap integrity and stack size in C#

Hi, I'm trying to track down a crash that happens when I stress my C# code and run in low memory conditions. However, in some cases, instead of getting OutOfMemoryException, my program will simply crash and exit. This is usually caused by memory corruption from overrunning a buffer or because of stack overflow (or corruption). So, is th...

How to allocate the memory from OS instead of increasing the JVM’s heap size?

I need to detect whether the file I am attaching to an email is exceeding the server limit. I am not allowed to increase the JVM heap size to do this since it is going to affect the application performance. If I don’t increase the JVM heap size, I will run into OutOfMemoryError directly. I would like to know how do allocate the memory...

how to choose the jvm heap size ?

Hi, What i usually do concerning the jvm heap size is setting the max value really high to avoid the infamous OutOfMemoryException. However, this strategy (or lack of strategy) doesn't seem to be really smart. :-). My question is how to choose the min and max values, and the difference between the two (should max-min be small or big?...

Does stack size grow during runtime?

I wonder if stack size can grow like heap does during runtime? ...

Java: Garbage Collection

I'm having an out of memory error. I have a large range of inputs (2^40), that is too large to hold at once. Each input is a String[]. Instead, I thought I'd run my test program on each input, write the results to a file, then discard the input. The length of the longest input is 42, so that isn't an error causing the overflow. I don't...

How can I avoid OutOfMemoryErrors when using Commons FileUpload's DiskFileItem to upload large files?

I am getting OutOfMemoryErrors when uploading large (>300MB) files to a servlet utilizing Commons FileUpload 1.2.1. It seems odd, because the entire point of using DiskFileItem is to prevent the (possibly large) file from residing in memory. I am using the default size threshold of 10KB, so that's all that should ever be loaded into the ...

Problem with priority_queue - Writing memory after heap

Hello again, I am trying to use priority_queue, and program constantly fails with error message HEAP CORRUPTION DETECTED. here are the snippets: class CQueue { ... priority_queue<Message, deque<Message>, less<deque<Message>::value_type> > m_messages; ...}; class Message has overloaded operators > and < Here I fill up ...

Can Sun JVM handle gigantic heap sizes without problems, and how?

I have heard several people claiming that you can not scale the JVM heap size up. I've heard claims of the practical limit being 4 gigabytes (I heard an IBM consultant say that), 10 gigabytes, 32 gigabytes, and so on... I simply can not believe any of those numbers and have been wondering about the issue now for a while. So, I have thr...