Ammar
You can't pass that to the thread.
Nils
What is print?
Like puts() but without newline
Ammar
So this is where I am stuck now.
Try this one: char *newstack = (char *)mmap(NULL, 8392704, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0);
Ammar
What is map()?
mmap I meant.
Ammar
That's for 8 MB stack.
Nils
That's for 8 MB stack.
Damn that's huge lol
Ammar
Reduce it if you want to.
Ammar
However, this does not mean your thread will consume 8 MB physical memory for the stack.
Ammar
? 🤔
mmap allocates virtual memory. It is only physically used when you read/write to it.
Naveen
class A { void display(){ sop("test"); } } public class Main { psvm(...) { A a1 = new A(); a1.test(); // 1 new A().test(); // 2 } } What is the difference between 1 and 2?
Ammar
So for example you map 10 MB of memory. You only read 10 bytes, it only uses 10 bytes physical memory. Not really sure about the calculation, but that is the simple illustration.
Dima
Lol
Ammar
Ah but it's allocated
Allocated does not mean physically uses the memory.
Ammar
For example, malloc(1024*1024*1024) won't make your program directly consume 1 GB of memory. It only uses 1 GB of memory if your program read/write to that allocated memory.
Ammar
What?
As what I say, which part I need to explain more?
Vitaliy ◀️TriΔng3l▶️
But for a simpler example, you write 1 byte, and 4 KB of physical memory will be allocated (for the page you wrote that byte to)
Vitaliy ◀️TriΔng3l▶️
if the page size is 4 KB on the target platform
Ammar
if the page size is 4 KB on the target platform
Oh I see, so it depends on the page size.
Vitaliy ◀️TriΔng3l▶️
Oh I see, so it depends on the page size.
Virtual memory is managed in pages, yes
Konstantin
As what I say, which part I need to explain more?
The part "It only uses 1 GB of memory if your program read/write to that allocated memory.". It's a bit confusing. Are you saying that I can do the following on a machine with 2GB of RAM? x = malloc (1GB) y = malloc (1GB) z = malloc (1GB)
Hadaward 'Solly'
what's the C telegram group for sharing ugly code?
Ammar
The decision of using large chunks or small chunks depends on the mmap threshold, this can be configured with constant option called M_MMAP_THRESHOLD.
Ammar
You can search for that constant to explore more.
Ammar
By default, malloc(1024*1024*1024) will always use mmap. Since DEFAULT_MMAP_THRESHOLD_MAX on: > 32-bit systems is 512*1024. > 64-bit systems is 4*1024*1024*sizeof(long).
Ammar
Except you modify the threshold.
Ammar
I just realized it is mentioned on man 3 mallopt.
Konstantin
Thanks, I learnt something new today. https://stackoverflow.com/questions/10966121/when-should-errno-be-assigned-to-enomem
Hadaward 'Solly'
http://t.me/c_cpp_india
that was smooth af
Ammar
Thanks, I learnt something new today. https://stackoverflow.com/questions/10966121/when-should-errno-be-assigned-to-enomem
This is different topic, but related. However, I just learned about /proc/sys/vm/overcommit_memory after reading this. Nice sharing, thanks.
Vlack
Guys, I've got a byjus ias tab, but it's locked and I can't access anything other than the course in it, can someone help me use the tab for other purposes
Chinepun💛
I just learnt how to write a makefile and it looks well but when I type "make" in my VS Code terminal,it doesn't recognize the command.Can someone pls help me with this?
Chinepun💛
Im using Windows
Nils
Im using Windows
Install by hand then
Dima
Too bad
Chinepun💛
Sad
Pls why is that?
Chinepun💛
Install by hand then
How should i do it then?
Nils
Pls why is that?
Windows is an operating system that limits your creativity in programming and has no proper package manegement
Nils
How should i do it then?
Let me spoon-feed you with a link
vinícius*
You can either use some reimplementation, such as the one by Visual Studio, or use a port such as the one in Cygwin
Nils
Let me spoon-feed you with a link
AG7💛 https://stackoverflow.com/questions/32127524/how-to-install-and-use-make-in-windows#32127632
Nils
Thank u
Next time visit your favorite search engine and type in your question before asking here
ɴꙩᴍᴀᴅ
How should i do it then?
Install linux or bsd on a side disk and use that system as a dev environment. You can still have dual boot and use windowze for gaming and stuff
Anonymous
Hi
Reeta
Hey 👋
Anonymous
Hey 👋
Hi there how are you?
Konstantin
Install linux or bsd on a side disk and use that system as a dev environment. You can still have dual boot and use windowze for gaming and stuff
Windows Subsystem for Linux will do the trick without dual boot. Just go to Windows Store app and search for "Ubuntu"
Emre
Hey guys idk how pointers work, can you suggest me some good sources to learn?
Anonymous
Guys
Anonymous
Guys
I'm a completely beginner with programming I want to know, your personal opinion about it and if you can tell me how to became better
Emre
Thank you!
Anonymous
Thanks for the ebook
Anonymous
Buuut I ask I you can tell me about it,
ɴꙩᴍᴀᴅ
Buuut I ask I you can tell me about it,
Asking about opinion is mostly going no where since each of us has different point of views. You want to learn to code, then practice. A lot. Read how the language works, learn algorithms, focus on one thing... it takes time. Shortcuts endup being useless. "learn how to code in 48 hours" are scam tutorials. I had a teacher that told me once "Learn how to program well, takes about ten years of daily work. Don't rush." I agree with it, but some people don't
Reeta
Hi there how are you?
I'm fine 😊, wbu?
V
hi guys, could you help me with codewars 4 kyu? I've done with it, but I have 1 warning because of compiler I guess. I was trying to google that warning, but only found suggestion about "return 0" in main() function (codewars have no main() in yourself tasks :\) and something about -Wall (codewars have no possibility to setup compiler args too :\). Code is here: https://pastebin.com/mdXFnQYA and yeah, code is a bit strange because that task requires to not use function like stoi, atoi or boost, so I had to write function like this