Manav
If you want you can send one yourself
Jose
And?
The same for you: and? I'm not responding the op, i responsed the (wrong) answer
Jose
What is this group for? Asking programming related questions or being harassed for not find it ourselves?
Jose
(No, it's not a meta question)
Jose
If you want you can send one yourself
I'm not versed in profiling... If I send something wrong, the disparagement will be worse, even
Manav
The same for you: and? I'm not responding the op, i responsed the (wrong) answer
I am responding to you. You care more about someone's answer, so do it yourself. 1. It's not harassment to ask someone to google. 2. It's considered good practice to not spoonfeed people. 3. If you feel like someone has given a "wrong" answer, answer them yourself the way you like it rather than demanding others to do so. 4. No one's ansking you to send a complicated example, send a simple one. If it's incorrect we'll correct you, you'll learn a few things, they'll learn a few things, even we could learn from it. Everyone benefits.
Manav
The point 1 is false. It's considered rude to ask someone to google. If you don't want to answer, don't answer. It's the equivalent of "don't ask to ask". Evidence: unix stackexchange: https://unix.meta.stackexchange.com/questions/7089/why-is-it-if-anyone-asks-a-question-no-one-can-ever-just-give-the-answer-for-th
It's not considered rude when the first google search for "how to use valgrind, massif" answers the very thing they're asking for. All we want is for them to see for themselves what that profiler is. They can ask their question if they're stuck with valgrind. No one's stopping them
Jose
I am responding to you. You care more about someone's answer, so do it yourself. 1. It's not harassment to ask someone to google. 2. It's considered good practice to not spoonfeed people. 3. If you feel like someone has given a "wrong" answer, answer them yourself the way you like it rather than demanding others to do so. 4. No one's ansking you to send a complicated example, send a simple one. If it's incorrect we'll correct you, you'll learn a few things, they'll learn a few things, even we could learn from it. Everyone benefits.
Point 2, false: Don't create a group for help people with programming questions if you don't be able to spoonfeed them. Some topics are obscure or unknown and spoonfeed is the only good practice. The good practice is "don't assume everybody will know how a profiler is or what massif is, without prior knowledge before". No quotes, international group and all levels of english would mistranslate massive with massif, with no indication it's a program itself
Manav
Point 2, false: Don't create a group for help people with programming questions if you don't be able to spoonfeed them. Some topics are obscure or unknown and spoonfeed is the only good practice. The good practice is "don't assume everybody will know how a profiler is or what massif is, without prior knowledge before". No quotes, international group and all levels of english would mistranslate massive with massif, with no indication it's a program itself
That's for the group owner to decide. The rules dictate this already. "You should not ask questions without checking your problem in Google or any other search engine. Doing so will result in a warning. Following this, check the Resources section of this group to see if your question has an answer there." From the rules.
Manav
The very first thing you do when optimizing is to measure. Profilers are the thing you need to be comfortable with, that's the intention behind them (Pavel) to say no to the op's request of not doing their work for them.
Manav
The op hasn't even shared their code, all we know is that they get an error for allocating too much. If we even want to give an example it would be too generic in their case. The best thing imo is for the op to see the software for themselves, try it out then come back here with better informed questions
Pavel
It will beneficial for him/her someone could show an example. Not everybody will find themselves everything they need... that's why zahra asked here
Missed most of your discussion but the first step here is to find a profiler (e.g. Valgrind doesn't work on Windows, and the reader can already have access to some other tools). It's literally two commands to get to the view I've shown (once you've got everything installed and the app compiled with symbols). So this is the small part of learning that I've just done myself, I didn't know anything about massif before today as well, if I was on Windows I would probably find some other memory profiler to showcase it.
VD
I actually didn't see the message above about the bad alloc, that changes things since that can probably be caught with just a debugger. Basically what Danya wrote just before my message
No a debugger can't help with this problem. Bad alloc happens when memory has already been exhausted. So problem could be somewhere else in the code. So like I said, he has to go through all his memory allocations and deallocations to see that everything is in order using tools like valgrind or a memory tracker
harmony5 🇺🇳 ⌤
Anonymous
Hello kings and queens I'm ur fellow mate looking a way to learn C can anyone recommend something like videos playlist or any course my goal is to atleast intermediate level of C I like hindi or English or Spanish videos I can't understand other languages
\Device\NUL
Which one is better, one call to read/write entire buffer or multiple read/write calls until end of buffer?
Adeyemo
Merry Christmas everyone
VD
Most likely the cause will be the same allocation that fails. Not guaranteed of course, especially in a big app, but I would start with that.
Well if it is the current allocation that is problematic, then you don't even need a debugger. The exception stack trace will show you which allocation failed.
Anonymous
Hello kings and queens I'm ur fellow mate looking a way to learn C can anyone recommend something like videos playlist or any course my goal is to atleast intermediate level of C I like hindi or English or Spanish videos I can't understand other languages
hey everyone i am looking for video in resources group but there are no videos over there.... a playlist would be helpful who teaches C till intermediate level if anyone has any pm me or just recommend in the chat
AbBãß
hey everyone... I just wrote a piece of code which included this: cout<<' '; (I pushed space button twice between ") the output was 8224 I couldn't understand why... does anyone know the reason ?
Kenshin
Which one is better, one call to read/write entire buffer or multiple read/write calls until end of buffer?
At their core, API calls that read, or write, an entire buffer are usually internally implemented by calling the API that reads, or writes, in bits, till the entire buffer is read from, or written to. The API that reads or writes the whole buffer is provided for convenience, and will do the scaffolding and sanity checks (error detection, pre and post contract conditions, etc) for you. Now, which to use? If you need all the data in the buffer before proceeding with your algorithm, then consider the API that reads, or writes, in whole. If you can use bits of the data as it comes in, then maybe the API that reads, or writes, in bits may be your preference.
olli
Which one is better, one call to read/write entire buffer or multiple read/write calls until end of buffer?
It depends what you want to achieve, if you want to optimize for raw performance and throughput it is probably beneficial to have a single read call; if responsiveness is your primary concern, issue multiple and process the data as it becomes available. Either way, probably best to do some measurements for your use case. Additionally, it probably also depends which APIs you are talking about. Many current OS run with Spectre and Meltdown mitigations enabled, these add a significant overhead to every system call which can hurt the performance when issuing many small reads that each have to trap into the kernel. W.r.t page-size, it depends how you are allocating the memory. The smallest memory region the OS deals with is a single page. No matter which byte you touch within the page the OS has to 'map' the whole page. I would assume most heaps (new/delete/malloc/free) are clever enough to try and use most parts of the page, no matter how big your allocation is and it shouldnt' really matter in this case.
Anonymous
hey everyone i am looking for video in resources group but there are no videos over there.... a  playlist would be helpful  who teaches C till intermediate  level if anyone has any pm me or just recommend in the chat
Danya🔥
Anonymous
Anonymous
Russian lang is very difficult 😂 I'll take months and months to learn it
Danya🔥
Russian lang is very difficult 😂 I'll take months and months to learn it
Just read the recommended books in English. Or try finding university courses from the top universities
Stefan
Russian
cyka blyat idi nahui
Rose
Another one bites the dust...! Banned Stefan. Reason: no, you, honey
Ahmad
/start@MissRose_bot
Rose
/start@MissRose_bot
Heya :) PM me if you have any questions on how to use me!
Ahmad
Pm
Ahmad
/start@MissRose_bot
Rose
/start@MissRose_bot
Heya :) PM me if you have any questions on how to use me!
Chat Boss
@unwr22 sent a huge message, it has been re-uploaded as a file Hi guys! I recently decided to remember my old skills of writing in C++, got to threads and caug..
UnknownWarrior22
Hi guys I recently decided to remember my old skills of writing in C++, got to threads and caught unexpected behavior. Console messages are printed in the correct sequence, but with incorrect delays. Namely, HERE3 is printed only after 10 seconds, that is, after the delay on line 16 is performed. What could be the cause of the problem? MacOS 14, M1 Pro, GCC13 (brew)
Chat Boss
@unwr22 sent a huge message, it has been re-uploaded as a file main.cpp #include <iostream> #include <thread> #include <chrono> int main(){ std::cout << "..
UnknownWarrior22
CMakeLists.txt cmake_minimum_required(VERSION 3.10) project(Locker) set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD_REQUIRED True) set(CMAKE_CXX_FLAGS "-O0") add_executable(Locker main.cpp)
UnknownWarrior22
Build command cmake -S . -B build && cmake --build build
UnknownWarrior22
I apologize for the inconvenience, but the bot does not allow me to post the code with a message :( However, it can be viewed in the file he sent.
VD
Hi guys I recently decided to remember my old skills of writing in C++, got to threads and caught unexpected behavior. Console messages are printed in the correct sequence, but with incorrect delays. Namely, HERE3 is printed only after 10 seconds, that is, after the delay on line 16 is performed. What could be the cause of the problem? MacOS 14, M1 Pro, GCC13 (brew)
It is not weird. That is the behavior I would expect on most implementations that buffer the output. The problem is that while printing HERE3, you don't use std::endl. So though the write has been processed, it is still sitting in the output buffer waiting for the output buffer to become full. On implementations where standard output is line buffered, you can see HERE3 printed earlier by just adding a \n. std::endl would work always
Bloods
who is looking for a programmer?
Erik
Hi, the executable of my project is in a folder inside the build folder. The executable needs to read some files from another folder within the same project. It works fine when providing the specific path from the executable to the files. However, if I move the executable to another folder, the code doesn't work anymore. I've looked into absolute paths, etc. Do you have any advice?
Danya🔥
That are available at compile time and are static
Danya🔥
https://github.com/vector-of-bool/cmrc
Danya🔥
You can use this
VD
Hi, the executable of my project is in a folder inside the build folder. The executable needs to read some files from another folder within the same project. It works fine when providing the specific path from the executable to the files. However, if I move the executable to another folder, the code doesn't work anymore. I've looked into absolute paths, etc. Do you have any advice?
Usually when you create a project you have specific locations for resource files wrt to the project root that is always fixed. So if you must absolutely move the resource files around, the better way to do it would be to have a config file which specifies the location and you can read the config file from your code to get the location.
VD
who is looking for a programmer?
I am looking for one to share drinks with. But I wouldn't want to do it with a random guy on telegram
Erik
Thank you
emiteclap
hi i have a question: in the interpretation process of a line of code the AST can only be used to reppresent expressions or also for statement like PRINT or INPUT ecc?
Rose
User Juli has 1/2 warnings; be careful! Reason: php homework ad
Never Spam Bot
See spam? Quote it and send /spam That helps to block spammers who joined the group before the bot was added.
Édrick
hi guys, i'm writing a custom string class as an assignment. currently my constructor for a string of length n looks like this: MyString(size_t n) { char *ptr = (char *)malloc(n + 1); ptr[n] = '\0'; m_strptr = ptr; std::cout << m_strptr << "\n"; }
Édrick
however, this leads to UB as memory is uninitialized and my get_length method, which counts chars until it encounters'\0' doesn't work with this my question is what should i initialize my memory with? note that according to the task the only member of the class i am allowed to have is the pointer (m_strptr), i cannot store the length in the class.
Édrick
With new char[n]{}, it will help you initialize the array to all '\0'.
yes and i don't want that because the way i check for the length is by seeing when is '\0' encountered for the first time: size_t get_length() { size_t n = 0; while (m_strptr[n] != '\0') { n++; } return n; }
Édrick
hi guys, i'm writing a custom string class as an assignment. currently my constructor for a string of length n looks like this: MyString(size_t n) { char *ptr = (char *)malloc(n + 1); ptr[n] = '\0'; m_strptr = ptr; std::cout << m_strptr << "\n"; }
I changed the constructor to this now: MyString(size_t n) { char *ptr = (char *)malloc(n + 1); memset(ptr, '-', n); ptr[n] = '\0'; m_strptr = ptr; } which sets all characters to '-' as a placeholder lol. i don't know what's the best practice for this but i guess my task does not prohibit that any way to improve it?
Vincent
Maybe you could modify the constructor to take a padding character as a parameter (and make it default-valued). BTW, it is more intuitive to allocate a n+1 array for a string of size n.
Vincent
😅 missed that...
Francesco
good evening everyone, I'm doing a project in which I have to write a C program to solve the knapsack 0-1 problem, I made the serial version, but I can't make the one with MPI + OpenMP work well, can anyone help me?
Rose
Purge complete.