Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.

memory_limit on Cloudron Manifest in bytes and how Cloudron UI shows it / converts it

  • I'm probably overthinking this and math is not my strong suit so please forgive me. I'm posting this for two reasons: 1) To learn how this works for custom packages, and 2) To see if there's a bug or anything in the other packages I was using to compare with and how Cloudron UI displays them.

    I was trying to look at some of my apps and noticed an odd behaviour, and this made me dig into the memory_limit set in the app packages, which made me wonder how these numbers are arrived at / displayed in the UI.

    I noticed in nodeBB it has a value of 1000 MB as the memory limit instead of showing 1 GB as other apps do once you hit the 1 GB max memory on the Resources tab. This lead me to look at how the package was built, and I was expecting to see the value in bytes as 1000000000 bytes, but instead I see 1048576000.

    How did 1048576000 come to be, how was that number arrived at?

    I feel like I'm missing something obvious here, and math is not my strong suit so I'm sure I am missing something haha. I guess this comes down to if we're converting in decimal or binary? But even in binary, if I did the math right (likely didn't, lol), the bytes should then be 1073741824, right? Perhaps that's why the Cloudron UI is showing 1000 MB instead of 1 GB?

    If so, can I fix it in the Git package so I feel like I fixed something? 😛 hahaha

    Otherwise please explain the math to me so I can understand when trying to set the appropriate value in a custom package that I may look to making soon. Thanks in advance. 🙂

  • Here's what NodeBB shows btw for 1 GB (note: 1000 MB)

    Here's what another app like Gitea shows for 1 GB:

  • a52e2721-d37e-4206-ae02-d23f1420866e-image.png

  • App Dev

    @d19dotca it's because of

    This value, 1048576000, is actually equal to 1024 * 1024 * 1000, so it really does use 1000MB, not 1024, hence not 1GB (using binary units)

  • @mehdi Yes I saw that part, that's where I got the 1048576000 from and it got me digging into it further. I guess then the display is using binary in Cloudron UI so the value it's set to isn't quite 1 GB in binary so it shows 1000 MB. Interesting. That seems wrong to me though, I assume the value in that manifest should actually be 1073741824 to match others that are 1 GB. Right?

    Example: 1073741824 is what's set for Bitwarden:

    Am I right in assuming then from this that the Cloudron UI basically shows in Decimal, and not Binary? But ideally the Manifest should be in Binary still so the UI shows the more expected typical numbers and increase segments, right?