I am infrequently getting an "Invalid pointer operation" error on a GET. When this does happen subsequent GETs also may get the error and eventually XData service fails to respond. I understand that this invalid pointer error error may indicate that an attempt has been made to free an object that has already been freed. After creating the Result object in the service function I am using the statement TXDataOperationContext.Current.Handler.ManagedObjects.Add(Result). Result is not specifically freed elsewhere.
I am still relatively new to XData so would appreciate any suggestions on where to look for the cause of the error.
Are you sure this is the only code you have? I don't see any problem with it.
Note that you don't need to call ManagedObjects.Add(Result), XData already automatically destroys the object being returned by the function.
What is common to happen is when the returned object also has an associated object. By default, XData will also tries to destroy such object. For example, suppose TServerVersion has a property Obj: TAnotherObject. Then XData will destroy Obj too. If TServerVersion calls Obj.Free in its destruction, an invalid pointer might happen.
The easiest way to solve this problem is to add a [JsonManaged] attribute to the TServerVersion class, telling XData to never destroy any associated object of the class.
Thanks for the information about the Result object.
I am pleased to say that I have now spotted my problem. I am using the CodeSite debugging tool from Raize. It was creating an object which appears to be conflicting with the XData routines. Dropping Codesite completely seems to be working perfectly. I should have just stuck to your excellent TMS logging system!