heap

C free char* allocated on heap

Is there a memory leak in the following code example as I have allocated memory on the heap for name which hasn't been freed? If I add free(person->name); before the free(person); line then I get a runtime error in VS "CRT detected that the application wrote to memory after end of heap buffer". header.h: #ifndef HEADER #define HEADER ...

Have PHP dump heap on OutOfMemory exception

I am currently debugging a script that constantly runs into OutOfMemory exceptions. It is run as a cronjob and usually runs fine, but when the cronjob wasn't run for a while (for whatever reason) the script has to handle to many elements that queued up and will run into a OutOfMemory exception. From examining the code I was not able to ...

How to efficiently implement an immutable graph of heterogenous immutable objects in C++?

I am writing a programming language text parser, out of curiosity. Say i want to define an immutable (at runtime) graph of tokens as vertices/nodes. These are naturally of different type - some tokens are keywords, some are identifiers, etc. However they all share the common trait where each token in the graph points to another. This pro...

Memory space required for a Static String constant in Java?

How much memory will JVM Allocate to 1) Static String 2) Static Integer I am exploring this issue as I am getting Heap Memory Out of Memory Exception, I have in my application 8 constants file and each file has almost near to 300 Static Constants. Is that a good practice to declare all the constants as a Static or any other practice c...

What is a contiguous memory block?

Just like in the title, what is a contiguous memory block? ...

Heap insert, delete k elements

Hello, I have the following problem (I think it's well known/standard) that I am thinking at: Verify that listing k smallest elements in a binary min-heap is O(k). I was thinking at traversing the big min-heap in BFS, maintaining a min-heap instead of a simple queue. Initially, the auxiliary min-heap contains the root of my big min-he...