You are not logged in.
Pages: 1
Hi
what is the problem with this code:
https://gist.github.com/a-nouri/d5032e0 … 66a2af7bc9
I got too many connection error after using service for hours.
Offline
I can't really comment on the use of mORMot (I only use a small portion of it).
But I do see some issues with your code.
*) On line 10 in GetConnection.pas you get a pmoConnection. Line 11 sets result to true if pmoConnection is not nil.
But.... if it is nil, it does execute line 12 where you access pmoConnection.IsConnected. If pmoConnection is nil this will result in an (silent?) exception (access violation) which you don't catch.
*) On line 8 of SaleOrderService.pas you do GetConnection(). GetConnection is a function which returns a boolean result. You don't check if this was successful and go on in the code as if it was. You need to exit the function if it was unsuccessful. Because the out of GetConnection could be nil (so LDBConn would be nil). This can also cause silent exceptions (also access violation).
I'm not sure if these 2 problems could cause your issue over time but it's something to fix ![]()
Offline
thanks. You are right. but problem is not this. it works. I will do your suggestion. but I think problem is not there.
Last edited by anouri (2026-02-16 09:23:23)
Offline
but I think problem is not there.
Then you might want to find out how many connections there are (at that point) and why the pool isn't releasing them if they are outdated.
And if there are too many, is this because this is a new thread each time, or that there is something wrong with releasing or reusing the connections in the pool?
You can't really see that from this snippet of code so you might have to explain exactly how fast, how many times, and in what context this is called (i.e. how this code is used).
And if ThreadingMode is set at tmMainConnection then it shouldn't even create new connections at all (and reuse the main connection).
Offline
Pages: 1