Skip to content

fix the calculation of RAM in MEM to ensure MEM_MAX_THREADS works cor…#545

Open
nazarenkomykyta wants to merge 2 commits into
d99kris:masterfrom
nazarenkomykyta:master
Open

fix the calculation of RAM in MEM to ensure MEM_MAX_THREADS works cor…#545
nazarenkomykyta wants to merge 2 commits into
d99kris:masterfrom
nazarenkomykyta:master

Conversation

@nazarenkomykyta

Copy link
Copy Markdown

Bash completely discards the remainder in this division; that is, if we run make.sh on a machine with a non-standard amount of RAM, for example, on SBC with 8.5 GB of RAM - then after this conversion, we’ll end up with exactly 8 GB, which is incorrect.

…rectly

Bash completely discards the remainder in this division; that is, if we run make.sh on a machine with a non-standard amount of RAM, for example, on SBC with 8.5 GB of RAM - then after this conversion, we’ll end up with exactly 8 GB, which is incorrect.
@d99kris d99kris self-assigned this Jun 27, 2026
@d99kris

d99kris commented Jun 28, 2026

Copy link
Copy Markdown
Owner

Hi @nazarenkomykyta - thanks for contributing. I agree the current calculation is not perfect. The rounding to full GB was intentional though, but I'm open to changing that to perhaps round to nearest 512 MB. I suspect going to more detailed level will lead to "wrong number" as the number reported by these tools differs a bit from actual physical mem size.

I have attached a patch which seems to work OK on a couple of my test systems (mac, linux, openbsd). Could you try it out and see if it would work for your systems too?
nchat-make-mem-v1.patch

@nazarenkomykyta

nazarenkomykyta commented Jun 29, 2026

Copy link
Copy Markdown
Author

Your patch makes sense.
But I think we need to use the same MEM_DIVISOR for Linux ( 1024 * 1024 ).
Tested on OpenBSD / amd64.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants