Will it work as a malware? Or will it only occupy RAM just once? | Sololearn: Learn to code for FREE!

+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

7/1/2022 10:04:25 AM

Unwanted Blue

7 Answers

New Answer

+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.

+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 fast..... Now that you have confirmed , I don't need to keep the tag 'virus' therefore I have removed it.

+1

im to scared to touch

+1

Brian new is kinda a wrapper around malloc. It does a few additional things, but it does a heap allocation for the object

0

i dont know c++ so I dunno but ill say this: you hacker you lol

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.

0

Unwanted Blue yes, I overlooked the new. How about using goto? Or did I miss some advantage of using for?