Sunday 25 April 2021

Java Heap

I'm not a Java guy, and recently I've found out about the -Xms and -Xmx settings that you can use when starting the VM to set the initial and maximum Heap size. Because of it I've been investigating a bit and I'll write it down here.

These settings quite surprised me, cause while node.js also has a --max-old-space-size setting that allows you to set the maximum Heap size, in .Net you have no control at all on the Heap size.

Before continuing, just some basic explanation. In 64 bits systems each application has an enormous, independent, Virtual Address Space available where it can reserve memory (in theory it's 128-terabytes, but the OS can set lower limits). What is really important is the Physical Address Space that is shared by all applications. An application can reserve memory in its VAS for some future use without really writing anything to it, so that's not taking up any Physical Memory. When you really need to use that memory it's when it has to be mapped to the common Physical Address Space, and this Physical Address Space is limited by... well, it's obvious, by the Physical and expensive RAM that you have bought for your system. You can check this link showing a good example with a native application in Linux. We could say that the Virtual Memory consumed by a 64 bits application is not particularly relevant, it's the Physical Memory who matters.

The Java Heap, memory where Java stores objects (those that you create with new) and that is taken care by the Garbage Collector, is not the only memory used by your Java application (though normally it's the main one). You obviously have the stack, and then several additional areas where the class definitions, code, and other structures are stored. This is nicely explained here. You can expect similar memory layouts for other Virtual Environments (.Net, Node, Python...).

The -Xmx setting makes sense to me. You set the maximum size that the application Heap can reach. This limit applies to the reserved memory in your Virtual Address Space, so obviously it also limits how much Physical Memory (Resident Memory) your heap will take up. When your heap is full and can not grow further, either the GC manages to release some space or your application will crash. I guess the idea behind this is to force more GCs to happen once an application is taking up much memory, rather than allowing it to continue to take up more and more memory. This way the application plays cleaner with other applications. Otherwise, if you have an application that has a serious memory leak, it would continue to grow until it takes up all the available physical memory and eventually crashes, but during that time it would be causing other applications that are behaving OK to GC more often or directly crash.

The reason for the -Xms setting is a bit less clear. You are setting the initial size of the Heap, so you are reserving that space in the huge Virtual Address Space of your application, but it won't be using physical memory until it really fills the addresses in your heap with something. Well, with this initial reservation you make sure that your heap takes up a contiguous space, which is better for performance. Apart from that, the main point is that I think GCs won't be conducted until you have filled this "minimum heap size" so your application will work faster until that moment is reached. That's the reason why sometimes it's recommended to run your application with Xms and Xmx set to the same value. You decide how much memory you allow your application to use (without being a burden for other applications on that machine), and let it run freely without Garbage Collecting interferance until the limit is reached. Also, as your heap has a fixed reserved size, you avoid the costs of resizing it.

I've been doing some tests with the Xms value, as there was some wrong information in different posts and I wanted to confirm that this value has no effect at all in the initial Physical Memory consumed by your application. To see the Physical Memory (Resident Memory) and Virtual Memory consumed by a process in Linux the best command that I came up with is:
top -p pid

I'm running a sort of "Hello World" Java application on Ubuntu, OpenJDK 64-Bit Server VM (build 14.0.2+12-Ubuntu-120.04, mixed mode, sharing). The application is not creating any objects other than the ones needed to read and write to the Console, so it's hardly putting anything into the Heap.

Running the application without providing any -Xms -Xmx setting I get this:

So this JVM is already reserving a large amount of Virtual Memory (the total reserved memory is more than 4 GBs, and based on what we'll see in the next execution, I guess the Reserved Heap is like 1 GB), but the consumed Physical memory is pretty low, just 33 MBs

Runnng it with a -Xms12g setting (12 GBs) we get this:

The JVM is reserving 15 GBs of Virtual Memory (so, apart from the Heap itself there are 3 additional GBs reserved for other memory areas), but the consumed Physical Memory is just 87 MBs. Anyway it's interesting to see comparing both cases that just reserving a much larger Heap involves a slight increase in the consumed Physical memory.

I've done the same test in Windows, and I get 10 GBs of Virtual Memory / 20 MBs of Working Set for the first case, and 13 GBs of Virtual Memory / 60 MBs of Working Set for the second case. Notice that I've never managed to fully understand the Windows Memory metrics: Private Bytes, Working Set... so I won't further comment on it.

Sunday 18 April 2021

Red Dot

I've recently watched an amazing Swedish thriller, Red Dot. I had no particular expectations about it. I just found it somewhere, read that it was set in the Northern Sweden wilderness and hence imediatelly downloaded it, and contrary to my normal patterns, I watched it almost on the spot. I did not even check if it was a USA film recorded in Sweden or a Swedish film (which for sure would have raised my expectations).

Of course just the snow covered wild landscapes would already make the film worth a watch, but there's much, much more to it. The story is pretty thrilling. In my case I managed to empathize a lot with the main characters. An heterosexual young couple (I think I'm one of the less homophobic persons in this world, but I'm starting to get fed up of the current need to over-represent homosexuality everywhere), made up of a white Swedish man and a black (mixed-race I guess) woman. I liked this couple a lot, not just for the mixed race thing, maybe for their relation crisis, their hopes (they are at that age when you still have to take some decisions that will completely change the rest of your life for the best or the worse), the devotion that the guy felt for the girl (something that seems so alien to me...).

Well, whatever the reasons, the thing is that I really liked this couple, so when they start to get into real shit, with a sort of maniac redneck trying to hunt them down, the whole thing feels really painful. I won't discuss how unrealistic their capacity to survive in the freezing weather, bleeding, having drop into a frozen lake... is, in the end this is fiction... The action is fast paced, intense, and additionally, the story has a pretty interesting final twist, so all in all it makes a really, really good experience.

Sunday 11 April 2021

Father McKenzie

I'm a proud and regular reader of FDeSouche. It's an essential source of information to understand to what extent European society (particularly France) is crumbling under the weight of the Islamic invasion and the Far-Left mental disease.

Last week they published an entry announcing the death of one regular reader that used to contribute with his comments to some of the news, "Father McKenzie". He used to do some very smart and ironic contributions and the FDeSouche team seleted a couple of his comments. I never got to know this person, but based on those comments, and at times of war like these, I can easily think that we were on the same side of the frontline. I'll translate (to my crappy English from my poor French skills...) one of his comments, and leverage the occasion to tell him: "Repose en paix".

One day, historians, if any decent ones remain, will write that right at the time when our Western Societies were about to reach by their own efforts the social and political maturity, become fully pacified and get access to direct democracy, and maybe to a true distribution of power and national wealth, all of that was broken in a few decades by the evil means of the programmed invasion of hostile populations.

Maybe these historians, struck themselves by the historical regression thus created, will write from some hidden refuge in the Yukon Rocky Mountains or in the Chilean Andes.

It's not certain that they will still have readers, but later, much later, some Chinese, Korean, Hawaian of Japanese researchers will compile their texts and tell their students about the pre-Islamic past of the Euro-Asian Far West.

Then, in Seoul, Honolulu, Anchorage and Shangai, people will ponder, while listening to Jean Sébastien Bach, before the images of the excavations of Versailles, about the fate of civilizations and, as today travellers question themselves when seeing modern Egyptians and looking at the Pyramids, Kim, Chang and Lu will say "Are these people there the ones that built that?"

And the wind in the ruins will answer "NO"

Friday 2 April 2021

Faits Divers

The Criminality and Violence Levels in any middle-size French city are terrifying. I'm not talking about official statistics, I'm talking about what you can experience if you live there and/or you follow the news. This feeling of insecurity and violence grows year after year, and I sadly think that the country is now closer to Mexico or Colombia than to other European cities.

This insecurity is one of the main elements that rot the lives of normal French people, along with Islamism, Communitarism, Racialism, Anti-French Hatred, Decolonial and Indigenist movements, and any other monstrosities fed by Far-Left and "Far-Green" ideologies. Indeed, we can say that all the sickening "streams of thought" that I've just named give place to an increase in criminality and violence, as all of them converge in the idea that "the others" are the enemy and deserve no respect. "The others" are 99% of the time French citizens of no Muslim and no African "culture".

One can easily witness this "ensauvegement" of the French Society reading the "Faits Divers". Yesterday there was one of those "Faits Divers" that was particularly "edifying". If your French Language skills allow for it, you can read about it here, otherwise, continue reading...

Yesterday, an "incident" took place in a "Quartier Sensible" (Maghrebian-Muslim African ghetto...) of Pontoise, one city in the Paris outskirts. One inhabitant of this neighbourhood had stolen a motorbike belonging to one member of the "Gens de Voyage" community. "Gens de Voyage" are gypsies, well, sometimes they are not ethnical gypsies, but their behaviour and "cultural habits" are the same... So some hours later three gypsies (the owner, his father and one friend) showed up in the hood to get back their property. They came across the thief riding the stolen cycle, so they just ran over him with their car... cool. The criminal died few hours later. Other inhabitants of the area that were enjoying a barbecue (I should remind you of the fact that because of the pandemic France is under a rather strict confinement and such an activity is a deep irresponsability, apart from being totally forbidden) decided to intervene and attacked the gypsies, that opened fire killing another guy. There are 3 additional people hurt. Wow, "C'est ca le multiculturalisme"...

One can be quite certain that in the next hours there will be burned cars (maybe also one school and a sports area), the police will be attacked, the fire fighters also, and so on and so on, just the customary "reaction" from this kind of population. Because, of course, you know that you must always blame the Police, the French state (and in general any French citizen of European or Asian descent) for everything, absolutely everything...

Well, one could at least hope that in the upcoming incidents some other criminal from any of both sides will be "hurt".