How does a reference-counting smart pointer’s reference counting work?

I’ve seen two different non-intrusive approaches to this: The smart pointer allocates a small block of memory to contain the reference counter. Each copy of the smart pointer then receives a pointer to the actual object and a pointer to the reference count. In addition to an object pointer, each smart pointer contains a previous … Read more

java.lang.OutOfMemoryError: Java heap space in DBeaver [duplicate]

I encountered same issue: every time you get it, you have to allocate more space and run DBeaver itself first with additional flags -vmargs -Xmx*m. Replace * with 2048 or 4096. It doesn’t look like DBeaver takes garbage out when closing the script, so I had to restart application many times to check right amount … Read more

Can you obtain the size of an array allocated with new T[]?

delete [] does know the size that was allocated. However, that knowledge resides in the runtime or in the operating system’s memory manager, meaning that it is not available to the compiler during compilation. And sizeof() is not a real function, it is actually evaluated to a constant by the compiler, which is something it … Read more

Why 64 bit mode ( Long mode ) doesn’t use segment registers?

In a manner of speaking, when you perform array (“indexed”) type addressing with general registers, you are doing essentially the same thing as the segment registers. In the bad old days of 8-bit and 16-bit programming, many applications required much more data (and occasionally more code) than a 16-bit address could reach. So many CPUs … Read more

C++ (14) and manual memory management

Caveat: I stand by this answer since I think it presents a best practice which will improve ~95% of C++ code – probably even more. That said, please read the full comments for a discussion of some important caveats. Since it was my comment, here’s my presentation explaining this. In a nutshell: [Raw] pointers must. not. … Read more

Java using up far more memory than allocated with -Xmx

Top command reflects the total amount of memory used by the Java application. This includes among other things: A basic memory overhead of the JVM itself the heap space (bounded with -Xmx) The permanent generation space (-XX:MaxPermSize – not standard in all JVMs) threads stack space (-Xss per stack) which may grow significantly depending on … Read more

tech