From adc7a12773fa9062ef74ecc33d75de046b533a34 Mon Sep 17 00:00:00 2001 From: Wolfgang Draxinger Date: Sun, 15 Sep 2013 02:15:44 +0200 Subject: x11atomstuffer added --- samples/X11/x11atomstuffer/Makefile | 3 ++ samples/X11/x11atomstuffer/x11atomstuffer.c | 73 +++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 samples/X11/x11atomstuffer/Makefile create mode 100644 samples/X11/x11atomstuffer/x11atomstuffer.c diff --git a/samples/X11/x11atomstuffer/Makefile b/samples/X11/x11atomstuffer/Makefile new file mode 100644 index 0000000..cf1c234 --- /dev/null +++ b/samples/X11/x11atomstuffer/Makefile @@ -0,0 +1,3 @@ +x11atomstuffer: x11atomstuffer.c + $(CC) -o x11atomstuffer x11atomstuffer.c -lX11 + diff --git a/samples/X11/x11atomstuffer/x11atomstuffer.c b/samples/X11/x11atomstuffer/x11atomstuffer.c new file mode 100644 index 0000000..d2f338f --- /dev/null +++ b/samples/X11/x11atomstuffer/x11atomstuffer.c @@ -0,0 +1,73 @@ +/*------------------------------------------------------------------------ + * What happens if you stuff the X11 server with large and large amounts + * of atoms? When does it run out of memory? How is its performance + * impaired by this? This is a little program to experimenting with + * torturing the X11 server by overfeeding it with atoms. + * + * (c) 2013 datenwolf + * + * License agreement: This source code is provided "as is". You + * can use this source code however you want for your own personal + * use. If you give this source code to anybody else then you must + * leave this message in it. +------------------------------------------------------------------------*/ + +#include +#include +#include + +#include +#include + +#include +#include + +static int Xscreen; +static Display *Xdisplay; + +char const doitkey[] = "wastemyX11server"; + +int main(int argc, char *argv[]) +{ + unsigned int i; + + if( argc < 2 || strcmp(argv[1], doitkey) ) { + fprintf(stderr, +"***************** WARNING! *****************\n" +"\n" +"This program wastes serious resources of the\n" +"X11 server it is started on. Do not execute\n" +"this program on a production X11 session as\n" +"the allocated resources can not be reclaimed\n" +"without resetting or quiting the X11 server.\n" +"\n" +"To actually perform this, do the following:\n" +"\n" +"%s %s\n" +"\n" +"***************** WARNING! *****************\n", + argv[0], doitkey); + return 0; + } + + Xdisplay = XOpenDisplay(NULL); + if (!Xdisplay) { + fprintf(stderr, "Couldn't connect to X server\n"); + return -1; + } + Xscreen = DefaultScreen(Xdisplay); + + unsigned int r = getpid() ^ time(NULL); + + for(i=0; i < 0xffffffff; i++) { + char atomstr[33]; + snprintf(atomstr,32, "_wasted_0x%08x_0x%08x", r, i); + XInternAtom(Xdisplay, atomstr, False); + if( !(i % 0x00010000 ) ) { + fprintf(stderr, "%s\n", atomstr); + } + } + + return 0; +} + -- cgit v1.2.3