I have changed the value "max open files" to 655350. But I still got the "Too many open files" exception.
The version of my macos is 10.15.6
My test code:
public class MaxOpenFiles {
public static void main(String[] args) throws IOException {
OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean();
List<Socket> sockets = new ArrayList<>();
for (int i = 0; i < 20000; i++) {
sockets.add(new Socket("localhost", 8080));
if(os instanceof UnixOperatingSystemMXBean){
System.out.println(("Number of open fd: " + ((UnixOperatingSystemMXBean) os).getOpenFileDescriptorCount()));
}
}
}
}
Result:
