Will it work as a malware? Or will it only occupy RAM just once? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Will it work as a malware? Or will it only occupy RAM just once?

Hopefully it will occupy the whole RAM https://code.sololearn.com/c3bNfCOf8tGM/?ref=app

1st Jul 2022, 10:04 AM
Unwanted Blue
Unwanted Blue - avatar
7 Answers
+ 3
Yes, this would occupy the whole ram. But you have to know how OSes and virtual memory work. There is a good chance that the OS will just terminate your process if there are no more resources left and it can't provide more ram to the program. the tag virus is wrong though, a virus is a program that can self replicate. Usually by infecting other programs with its own code. edit: also you might want to allocate smaller chunks of memory at a time. tryong to allocate too huge amounts will always fail.
1st Jul 2022, 3:16 PM
Erarnitox
Erarnitox - avatar
+ 3
Erarnitox Thank you for your confirmation, and about the virus tag, I know that it's not a virus ,it's just a malware ; I used it just to seek attention from others so that I can get a response relatively faster..... Now that you have confirmed , I don't need to keep the tag 'virus' therefore I have removed it.
1st Jul 2022, 3:26 PM
Unwanted Blue
Unwanted Blue - avatar
+ 1
im to scared to touch
1st Jul 2022, 3:06 PM
Junior
Junior - avatar
+ 1
Brian new is kinda a wrapper around malloc. It does a few additional things, but it does a heap allocation for the object
2nd Jul 2022, 4:35 PM
Erarnitox
Erarnitox - avatar
0
i dont know c++ so I dunno but ill say this: you hacker you lol
1st Jul 2022, 10:19 AM
ρү૨œdԌ૨ ×
ρү૨œdԌ૨ × - avatar
0
Unwanted Blue I think this would only fill up the stack and then get terminated with a memory violation. There would be plenty of heap memory available. Use alloc or malloc to grab heap RAM. The for loops would run forever, as desired. Why not just use while (1) statement, or a goto statement to make a tighter loop.
2nd Jul 2022, 1:52 PM
Brian
Brian - avatar
0
Unwanted Blue yes, I overlooked the new. How about using goto? Or did I miss some advantage of using for?
2nd Jul 2022, 8:15 PM
Brian
Brian - avatar