PDA

View Full Version : Annoying People With Memory Leaks.


DANIEL2488
01-26-2008, 02:05 PM
Memory leaks are fairly easy to create. I'll give a few samples.


/* Memory Leak in C */

int main()
{
while (1)
{
malloc(sizeof(char));
}
return 0;
}




/* Memory Leak in C++ - Previous example works as well
but faster */

#include <string>

int main()
{
while (1)
{
new std::string;
}
return 0;
}



/* Memory Leak in D */

import std.gc;

void main()
{
std.gc.disable(); // IMPORTANT
while (1)
{
new Object();
}
}


Something that I've found to be true is that the smaller the thing you allocate, the greater the memory leak in a smaller amount of time. This means it takes less time to allocate space for a small data type like a character than a larger data type like a C++ string, or a D Object.

So what's the big deal, right? It's a memory leak, and Windows (and other OSes) forces the program to terminate or reduce its memory usage if it gets to a dangerous level.

The thing is, if the program doesn't quit, it really slows down the other computer. So here's what you do: you compile this with no terminal window/console, and it runs in the background, slowing down the victim's computer.

Not much of a tutorial, but hey, anyone got something apart from hacking soda vending machines?

Moonbat
01-26-2008, 02:37 PM
First programming-related tutorial I've seen in a while. This'll help people when they want an easy way to make someone mad. Nice job :D

I wrote a cookie-stealing tut, but that's basic stuff.

coz
01-26-2008, 05:12 PM
Nice job! I remember trying C and writing plenty of memory leaking programs. They were all command prompt programs but man could they slow a computer down. I hated it because it took like 5 mins for the program to fully crash and exit. Most of them leaked because of loops and invalid pointers. Anyway I found an interesting site about a week ago called http://www.firewallleaktester.com/. They have some useful programs.

DANIEL2488
01-26-2008, 11:34 PM
Thanks guys.

By the way, I forgot to add, Digital Mars makes the D compiler, and it produces MUCH faster files than GNU's C and C++ compilers. I'd suggest looking into the Digital Mars C++ compilers, because it looks like these guys kick GNU's ass.

gprunescaper
05-31-2008, 06:46 PM
Good writing. Keep up the good work. I just added your RSS feed my Google News Reader. GP (http://www.gprunescape.com/), RS GUIDE (http://www.runescape365.com/), RS-PL (http://www.runescape-power-leveling.us/),,MS-MESOS (http://www.maplestorymesos.us/), well, I love my site, let’s try our best together, size everyday, and think just do it, I can!