We've created a Datasnap service (with Delphi XE), using Bob Swart's white paper as a guide. It works fine, and we've deployed it to our test server.
Now a problem occurs, when we have executed a large number of requests (through JMeter), some sort of memory corruption occurs. Some requests succeed, some fail with an access violation. In the end, it has become so corrupt, that every request to our OWN (not the DSAdmin) methods responds with an access violation.
However, I can't get my hands on a stacktrace to get more info, because the exception is already catched in the processing of the request.
If I test heavily with the VCL version of this application, it remains working correctly.
Has anyone any clue what this could be, or experienced the same problem, or can you help me get the stack trace from a caught exception (in someone else's code, which I can't edit)?
Thanks in advance.
To log both caught and uncaught exceptions using JEDI JCL, you should install the JEDI JCL.
Then try some code like this code taken from
jcl\examples\windows\debug\framestrack\FramesTrackDemoMain.pas
:You should compile with full Debug information on in both the Compiler and Linker options in your delphi project options, for this to work.
Note that you don't have to call LogException, it's called automatically one you've added the exception notifier callback (JclAddExceptNotifier). don't forget to also call JclRemoveExceptNotifier, when the form or data module you are adding it from is destroyed, as shown here:
This is the usual initialization code:
Here's the JCL FramesTrackExample.dproj demo running:
For your purposes, change the code that adds a line to TMemo.Lines, to write to a log file on disk instead. If you already have a logging system, that's great, and if not, then consider Log4D.
Every new web service call is a new thread. Some resources can be allocated by previous thread when the next service call is coming and the new thread tries to access them. Or some resources may be released by one thread when another thread tries to use them. You should use TCriticalSection to make sure that all resources are available only for one thread. Also make sure that the TCriticalSection is a global variable and accessible by all instances.