Java using much more memory than heap size (or size correctly Docker memory limit)

Virtual memory used by a Java process extends far beyond just Java Heap. You know, JVM includes many subsytems: Garbage Collector, Class Loading, JIT compilers etc., and all these subsystems require certain amount of RAM to function. JVM is not the only consumer of RAM. Native libraries (including standard Java Class Library) may also allocate … Read more

String literals: Where do they go?

A common technique is for string literals to be put in “read-only-data” section which gets mapped into the process space as read-only (which is why you can’t change it). It does vary by platform. For example, simpler chip architectures may not support read-only memory segments so the data segment will be writable. Rather than try … Read more

What does “Memory allocated at compile time” really mean?

Memory allocated at compile-time means the compiler resolves at compile-time where certain things will be allocated inside the process memory map. For example, consider a global array: int array[100]; The compiler knows at compile-time the size of the array and the size of an int, so it knows the entire size of the array at … Read more

What is the difference between buffer and cache memory in Linux?

Buffers are associated with a specific block device, and cover caching of filesystem metadata as well as tracking in-flight pages. The cache only contains parked file data. That is, the buffers remember what’s in directories, what file permissions are, and keep track of what memory is being written from or read to for a particular … Read more

Why does appending “” to a String save memory?

Doing the following: data.substring(x, y) + “” creates a new (smaller) String object, and throws away the reference to the String created by substring(), thus enabling garbage collection of this. The important thing to realise is that substring() gives a window onto an existing String – or rather, the character array underlying the original String. … Read more

Redis cache vs using memory directly

Redis is a remote data structure server. It is certainly slower than just storing the data in local memory (since it involves socket roundtrips to fetch/store the data). However, it also brings some interesting properties: Redis can be accessed by all the processes of your applications, possibly running on several nodes (something local memory cannot … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)