Speicher füllen
von king-crash- SNIPPET_DESC:
- Reserviert schrittweise Arbeitsspeicher.
- SNIPPET_CREATION_TIME:
- 30.09.2022 09:03:35
- SNIPPET_PRUNE_TIME:
- Unendlich
- SNIPPET_TEXT:
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <string.h>
- #include <signal.h>
- #include <sys/wait.h>
- #define NELEMS(x) (sizeof(x) / sizeof((x)[0]))
- static int size_max_in_100mb = 300; // Maximal 30GB
- static int use_memory = 1; // Bei 0 wird der Speicher nur reserviert aber nicht tatsächlich genutzt.
- int main(void)
- {
- void *buffer[size_max_in_100mb];
- size_t size = 100000000;
- int count;
- {
- {
- if(use_memory)
- {
- }
- }
- else
- {
- puts("malloc meldet Fehler.");
- break;
- }
- }
- {
- count--;
- }
- for(;count>=0;count--)
- {
- }
- return 0;
- }
Quellcode
Hier kannst du den Code kopieren und ihn in deinen bevorzugten Editor einfügen. PASTEBIN_DOWNLOAD_SNIPPET_EXPLAIN