For purpose of an academic project I want to create a simple program to hang a computer by consuming all available RAM. I tried creating a string and increase its length using a while loop like string=string+string2
. I takes so much time when string2 is short, even though I could use 100% ram but at last I get a OutOfMemoryException and so much memory is freed. Is there any effective way of doing this?
Asked
Active
Viewed 522 times
-1

Rahul K
- 665
- 10
- 25
-
*" I want to create a simple virus program"* you may attract unwelcome attention with this description. Possibly better to say you want to develop a tool for stress testing low memory conditions. Unless of course you really *do* intend to create a virus? – Roger Rowland Nov 02 '13 at 09:59
-
It depends on how you define "virus" :P – Rahul K Nov 02 '13 at 10:06
-
A virus is a program; to build a program you need to know what you want and what is the best way to get it. From your description (+ your attempt), it is clear that you have a quite limited knowledge on this matter. To ask anything in SO you have to show a minimal understanding (, attempted solutions, research you did, etc.); on top of all that, you have to aim something worthy; and don't think that anyone will consider what you aim worthy at all. – varocarbas Nov 02 '13 at 10:10
-
1See this question: http://stackoverflow.com/questions/716798/maximum-net-achievable-memory – Szymon Nov 02 '13 at 10:14
-
Thanks guys.. And sorry for misunderstanding me, Well, please understand there are several ways to create a virus with bad intentions if I want (I already done this in cpp, now I'm not allowed anything other than vb.net). thanks – Rahul K Nov 02 '13 at 10:26
-
But I might be wrong... perhaps you aim something worthy (as seems to think other people). In any case don't think that your question (as you asked it) and the answer you got (and the ones you might get) has any true value (independently upon the virus thing; just from the reliable-information point of view) but well... (again some other people might think differently) – varocarbas Nov 02 '13 at 10:26
-
You want to hang a computer by creating a kind of infinite loop in a program, but you have already created viruses in the past? Don't get offended, but I would expect from a virus-developer to have more solid knowledge about certain issues. Don't misunderstand me, nothing to complain :) – varocarbas Nov 02 '13 at 10:30
-
@varocarbas I dont said virus Sir. I said a program that uses 100% memory. And if you consider something like `While(true){}` as a virus (well, its not memory consuming, dnt misunderstand again), yes I'm pretty good virus developer. And I'm going to destroy this world using some viruses when I get some time. thanks. – Rahul K Nov 02 '13 at 10:41
-
OK, ok, much clearer now. While(true) is more or less the same than what you asked. It is limited to the program and thus with no true capability to affect the whole system (neither memory, nor CPU, nor anything else). For example: 10 years ago it was possible to do many more (bad) things (systems were much less robust). This is basically the idea behind a virus: taking advantage from weaknesses. The weakness which your question intends to exploit is not a weakness at all. This was my whole point (also that "I want to create a virus" should only get as an answer not being taking seriously). – varocarbas Nov 02 '13 at 10:50
-
I used "virus" as a slang not like its exact definition. Btw, A 4 threads with infinite while loops can consume my corei3 100%. It cant hang whole system but running it forever cause some power loss atleast. :) – Rahul K Nov 02 '13 at 11:01
-
(the running-forever part is the most influential one, I think) As far as I started this speech regarding viruses; just wanted to clarify this last issue of exploiting weaknesses: nowadays the true weakness is the user. Executing the given "program" provokes most of the virus-related problems. It is pretty difficult for a virus to affect a nowadays computer/operating system without the user intervention; if the user executes it, then anything can happen. PS: I got the idea since the start but prefer to censor certain words/attitudes to make sure that their "coolness level" is minimum ;) – varocarbas Nov 02 '13 at 11:17
1 Answers
1
Not entirely possible as the OS will deal with the memory management thus you wont be able to do what you are trying to do especially in managed code. I also don't believe that an academic programme will have a course or instruct students to develop something like this. question sounds a little wierd

Ahmed ilyas
- 5,722
- 8
- 44
- 72
-
Not to mention that there are quite a few things on top of the "simple program" (CTRL+ALT+SUP, for instance). You can make the program to hang itself, not to hang the whole system. – varocarbas Nov 02 '13 at 10:24