Skip to main content

· 15 min read
Bartek Jabłoński

In short

  • Each object has memory overhead (from 12 to 16 bytes for metadata headers, references (4 bytes), memory for simple data type.
  • Processors (CPU) can be 32 bit (4 byte - supporting a maximum of 4 GB RAM) or 64 bit (8 byte). This means that the CPU downloads data from RAM in batches of 4 or 8 bytes at a time.
  • Padding - alignment to 8 bytes - i.e. objects occupy memory equal to a multiple of 8 bytes. This can be increased because it limits the use of the maximum heap to 32 GB.
  • The reference takes 4 bytes (32bit CPU or 64bit CPU with Compressed References (default)) or 8 bytes (64bit CPU).
    • Maximum heap for Compressed References = 32 GB - use of bit shift by 3 places due to the fact that the 8 byte always has three zeros on the right side. (8 byte because it is aligned to 8 byte padding). Therefore we can use 32 GB heap instead of 4 GB.
    • When we use a 64-bit CPU with Compressed References and increase the heap memory above 32 GB, we may have problems with the application and a significant increase in the heap occupied due to the change in reference memory from 4 bytes to 8 bytes for every object on our heap- e.g. a change from -Xmx31g to -Xmx33g may result in an increase in data seizure by 40% (depending on the data)

· 7 min read
Bartek Jabłoński

In short:

  • The memory of the String object consists of 24 bytes for metadata + the number of characters times 1 byte or 2 bytes depending on the coder value
    • Metadata: mark word x2 (4 bytes x2 = 8 bytes), class word (4 bytes), array reference byte[] or char[] (4 byte), hash (4 byte), hashIsZero (1 byte), coder (1 byte), padding (2 byte)
  • The String object has 2 additional flags:
    • when coder =1 then UTF-16 encoding (2 bytes per character)
    • when coder = 0 then LATIN-1 encoding (1 byte per character)
    • hashIsZero is a flag that tells whether the hash calculation has already been performed

· 4 min read
Bartek Jabłoński

I recently stopped using Spotify Premium and it has become more difficult to listen to music and podcasts on the plane. So far, I have downloaded mp3 and mp4 using online tools such as:

Unfortunately, tools of this type allow you to download individual videos and bombard us with a lot of invasive advertisements. To avoid these problems, we will write a script in Python which, after providing a link to a playlist or movie, will download an mp3 or mp4.

We will use the library pytube to write the script .

You can find the entire script in the repository gitlab: https://gitlab.com/bart_as93/youtube-downloader