heap

Malloc and scanf

I'm fairly competent in a few scripting languages, but I'm finally forcing myself to learn raw C. I'm just playing around with some basic stuff (I/O right now). How can I allocate heap memory, store a string in the allocated memory, and then spit it back out out? This is what I have right now, how can I make it work correctly? #inclu...

What's the Break instruction exception in windbg

I'm debugging some random crash bugs, but actually very difficult to go deep into. Because when i open crash dump, only find one error: 0:000> .exr -1 ExceptionAddress: 00000000 ExceptionCode: 80000003 (Break instruction exception) ExceptionFlags: 00000000 NumberParameters: 0 Actually i haven't set any hard-code breakpoint in co...

Why do threads share the heap space?

Threads each have their own stack, but they share a common heap. Its clear to everyone that stack is for local/method variables & heap is for instance/class variables. What is the benefit of sharing heap among threads. There are several number of threads running simultaneously, so sharing memory can lead to issues such as concurrent m...

In GDB, how to find out who malloc'ed an address on the heap?

I have a pointer in GDB, how can I find out where it was first allocated on the heap? In WinDBG, this can be done by !heap -p -a <0x12345678> after turning on gflags /i <*exe> +ust Since Valgrind can tell me where the memory is allocated (when it detects some leaks), I guess this is also possible? (This is NOT about watchpoint. This i...

Java heap bottleneck - how to identify the cause?

I have a J2EE project running on JBoss, with a maximum heap size of 2048m, which is giving strange results under load testing. I've benchmarked the heap and cpu usage and received the following results (series 1 is heap usage, series 2 is cpu usage): It seems as if the heap is being used properly and getting garbage collected properly...

What are the default maximum heap sizes for the various Sun JVM's?

One would think it would be easy to find a table that lists the default maximum heap sizes for the different JVM versions...but a quick search didn't find such a thing. So, what are the default maximum heap sizes for the various Sun JVM's? ...

mmap regions allocating from reserved stack space?

In our product we use a malloc implementation that relies exclusively on mmap for memory allocation. We also do a fair use of allocaing. We've just encountered a problem where mmap will allocate regions that should be reserved to stack space (thus causing very bad things to happen when one of our larger alloca's spills into the malloc'...

The direction of stack growth and heap growth

In some systems, the stack grows in upward direction whereas the heap grows in downward direction and in some systems, the stack grows in downward direction and the heap grows in upward direction. But, Which is the best design ? Are there any programming advantages for any of those two specific designs ? Which is most commonly used and w...

dynamically increasing java heap space

I have written a java program that tests the speed of a couple of multi-threading algorithms on different machines with various numbers of processors. On some machines, merge sort* fails because it requires a sizable heap space to work on very large arrays. I can easily change the java heap space myself before running the program, but ...

Reading/Writing self heap

Could the own heap space be readed? could the software be self modified in memory? I write some code to show the subject, am I reading own code at memory? how (if possible) to write it and change instruction on runtime? #include<stdio.h> #include<stdint.h> volatile int addressBase; uint8_t read(int address); int main(void) { ...

C++: TwoDimensional Array: One dimension fixed?

Hi, I need to pass a double [][6] to a method. But I don't know how to create that two-dimensional array. 6 is a fixed size (or a "literal constant", if my terminology is right), which the method accepts. I was trying something like this, but without success... double *data[6] = new double[6][myVariableSize]; So, the method really ...

Beginner question about heap and garbage in Clojure

I have a question about Clojure: I am trying to learn the language by going through Project Euler and I don't understand what is going on under the hood: The following code is designed to use return a list of all prime numbers up to lim. I would think that it should be O(n) in heap-space because I make a list of all the numbers up to li...

comparison of access performance of data in heap and stack

It is widely known common sense, that for most algorithms, allocating and deallocating data on the stack is much faster than doing so on the heap. In C++, the difference in the code is like double foo[n*n] vs. double* foo = new int[n*n] But there are any significant differences, when it comes to accessing and calculating with data ...

unsafe c# code causes heap corruption on 64 bit platform unless built for x86 platform.......

Hi all, I have a simple util that uses some unsafe code to get the file version information. when I compiled this as mixed platform (vs2008/.net 3.5) and deploy to 64 bit machine I get a heap corruption error. If I recompile as x86 then everything works.... This was suprising because of my understanding of the .NET Common Type Syste...

Eclipse heap walk

When debugging Java code, Eclipse has a feature that allows it to find all instances of a given type (via context menu in the Variables window). Is there any way to filter these programatically? For instance, I want all instances of class FieldInstruction where the_instance.getType().getName().equals("somestring") Evaluates to t...

Diffrence between stack memory and heap memory

Possible Duplicate: What and where are the stack and heap Where is heap memory and stack memory stored?I mean where on the harddisk?what are the limits of their size? ...

Does initialized java array go onto stack or heap?

void someMethod() { byte[] array = { 0, 0 }; } Will this array be stored in heap or on the stack? ...

smallish string array assigment causes segmentation fault...

Hello, My original code (following) gives a seg fault at the string array assignment at about num_atoms=150,000: int num_atoms=dimension[0]*dimension[1]*dimension[2]*prim_lat.size(); double superlat[num_atoms][3]; string current_occ[num_atoms]; Thinking this was a first instance of me hitting a stack overflow issue, and thinking you c...

Why does calling free () on a pointer allocated with 'new' cause heap corruption?

Does it actually work on some compilers/machines but on others it causes heap corruptions and crashes? Does anyone have any insight into what going on under the covers? ...

Best Table Engine for massively updated MySQL table. MyISAM or HEAP?

I am creating an application which will store a (semi) real-time feed of a few different scales around a certain location. The weights of each scale will be put in a table with only as many rows as scales. The scale app feeds the MySQL database a new weight every second, which a PHP web app reads every 3 seconds. It doesn't seem like ...