An access violation means that you're trying to access memory that doesn't belong to your process. I'm not sure where it's originating, that could be the server but I suspect the issue is at the client-side.
You're probably just forgetting to free memory somewhere.
I am using 2 threads, each declares seperate PGconn conenction object.
It connects e.g. 60 times, one connection from one thread, the other connection from the other thread, usually one after each other. And it fails at 61'st connection with access violation.
I already tried with PQconnect and PQsetdbLogin. I am using mututal SSL authentication with this connections, maybe this is the case?