heap corruption detected | C++

“Heap corruption” generally means you wrote into unallocated memory, damaging the data structures used to make the memory allocator work. There may be more problems, but the first one I see is on this line: This will write strlen(n) + 1 bytes to buffer, but buffer is only strlen(n) bytes long (the extra byte is the terminating \0.) Writing that extra byte results … Read more

Increase heap size in Java

You can increase to 2GB on a 32 bit system. If you’re on a 64 bit system you can go higher. No need to worry if you’ve chosen incorrectly, if you ask for 5g on a 32 bit system java will complain about an invalid value and quit. As others have posted, use the cmd-line flags – e.g. You … Read more

Casting a pointer to an int

I am writing my own functions for malloc and free in C for an assignment. I need to take advantage of the C sbrk() wrapper function. From what I understand sbrk() increments the program’s data space by the number of bytes passed as an argument and points to the location of the program break. If … Read more