Skip to content

Instantly share code, notes, and snippets.

@derpsteb
Last active April 5, 2023 13:03
Show Gist options
  • Save derpsteb/26723ea2d5a8e9bcea266d0715859e5a to your computer and use it in GitHub Desktop.
Save derpsteb/26723ea2d5a8e9bcea266d0715859e5a to your computer and use it in GitHub Desktop.

Increase number of inotify instances with: echo 1000000000 > /proc/sys/fs/inotify/max_user_instances

Increase number of openable files with: ulimit -n ...

Check hardlimit with: ulimit -n -H

#include <sys/inotify.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
int main() {
int i, fd;
for (i = 0; i < 1000000; i++) {
fd = inotify_init();
if (fd == -1) {
perror("inotify_init");
break;
}
}
printf("Created %d inotify instances\n", i);
pause();
return 0;
}
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <arpa/inet.h>
int main() {
int i, sockfd;
for (i = 0; i < 1000000; i++) {
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd == -1) {
perror("socket");
break;
}
}
printf("Created %d sockets\n", i);
pause();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment