Use of TMSStoredProc
-
- Posts: 38
- Joined: Wed 16 May 2007 01:12
Use of TMSStoredProc
I've got a memory leak somewhere, and I'm wondering if I get some help from you folks. Am I using TMSStoredProc correctly? In the code below, RTMetSP points to a TMSStoredProc object that is created at runtime. Each time the code below is executed, Params->ParamValues[] are updated, and the stored procedure is executed. Does this code look okay? Do Params need to be "cleared" between executions? Is there anything that can happen inside a stored procedure that will create a memory leak in a calling application?
Thanks very much,
Joe
TMSStoredProc *SP = RTMetSP; // pointer to stored procedure
TParams *P = SP->Params; // pointer to Params property
P->ParamValues["Device"] = Label;
P->ParamValues["DateTimeStamp"] = Now();
P->ParamValues["CommError"] = CommError;
P->ParamValues["OpStatus"] = OpStatus;
P->ParamValues["DeviceTimeStamp"] = DeviceDateTime;
P->ParamValues["Wspd1"] = Fmet->TenMin.Eng.Wspd1_1s;
P->ParamValues["Wspd2"] = Fmet->TenMin.Eng.Wspd2_1s;
P->ParamValues["Wspd3"] = Fmet->TenMin.Eng.Wspd3_1s;
P->ParamValues["Wspd4"] = Fmet->TenMin.Eng.Wspd4_1s;
P->ParamValues["Wdir1"] = Fmet->TenMin.Eng.Wdir1_1s;
P->ParamValues["Wdir2"] = Fmet->TenMin.Eng.Wdir2_1s;
P->ParamValues["Temp1"] = Fmet->TenMin.Eng.Temp1_1s;
P->ParamValues["Temp2"] = Fmet->TenMin.Eng.Temp2_1s;
P->ParamValues["Baro"] = Fmet->TenMin.Eng.Baro1_1s;
try { // test for C++ exceptions
SP->ExecProc(); // execute stored procedure
}
catch ( ... ) {
// handler for any C++ exception
}
}
Thanks very much,
Joe
TMSStoredProc *SP = RTMetSP; // pointer to stored procedure
TParams *P = SP->Params; // pointer to Params property
P->ParamValues["Device"] = Label;
P->ParamValues["DateTimeStamp"] = Now();
P->ParamValues["CommError"] = CommError;
P->ParamValues["OpStatus"] = OpStatus;
P->ParamValues["DeviceTimeStamp"] = DeviceDateTime;
P->ParamValues["Wspd1"] = Fmet->TenMin.Eng.Wspd1_1s;
P->ParamValues["Wspd2"] = Fmet->TenMin.Eng.Wspd2_1s;
P->ParamValues["Wspd3"] = Fmet->TenMin.Eng.Wspd3_1s;
P->ParamValues["Wspd4"] = Fmet->TenMin.Eng.Wspd4_1s;
P->ParamValues["Wdir1"] = Fmet->TenMin.Eng.Wdir1_1s;
P->ParamValues["Wdir2"] = Fmet->TenMin.Eng.Wdir2_1s;
P->ParamValues["Temp1"] = Fmet->TenMin.Eng.Temp1_1s;
P->ParamValues["Temp2"] = Fmet->TenMin.Eng.Temp2_1s;
P->ParamValues["Baro"] = Fmet->TenMin.Eng.Baro1_1s;
try { // test for C++ exceptions
SP->ExecProc(); // execute stored procedure
}
catch ( ... ) {
// handler for any C++ exception
}
}
Your code looks ok. Does the memory leak on each stored procedure execution, or only on executions that raise errors? What tool do you use to detect the memory leak.
Could you send me a complete small sample at sdac*crlab*com to demonstrate it, including script to create server objects?
Also supply me the following information:
- exact version of SDAC. You can see it in the About sheet of TMSConnection Editor;
- exact version of your IDE;
- exact version of SQL server and client. You can see it in the Info sheet of TMSConnection Editor.
Could you send me a complete small sample at sdac*crlab*com to demonstrate it, including script to create server objects?
Also supply me the following information:
- exact version of SDAC. You can see it in the About sheet of TMSConnection Editor;
- exact version of your IDE;
- exact version of SQL server and client. You can see it in the Info sheet of TMSConnection Editor.
-
- Posts: 38
- Joined: Wed 16 May 2007 01:12
Antaeus,
I'm not sure there is a memory leak, and if there is a memory leak, I'm not sure where it is. I'm fairly new to database stuff, so I needed to ask if my code looked okay. The application _sometimes_ acts as if there is a memory leak, but not all of the time. It's very strange. I will do some testing of the stored procedure calls in a small test program and I'll let you know how that looks.
Joe
I'm not sure there is a memory leak, and if there is a memory leak, I'm not sure where it is. I'm fairly new to database stuff, so I needed to ask if my code looked okay. The application _sometimes_ acts as if there is a memory leak, but not all of the time. It's very strange. I will do some testing of the stored procedure calls in a small test program and I'll let you know how that looks.
Joe
-
- Posts: 38
- Joined: Wed 16 May 2007 01:12
-
- Posts: 38
- Joined: Wed 16 May 2007 01:12
-
- Posts: 38
- Joined: Wed 16 May 2007 01:12
Using (Exception &E) still does not solve the memory leak in my case. I'm using RAD2007 with latest patches. The code now looks as shown below. If I call this code many times with the same data, there is a duplicate record exception on each call after the first one. The memory leak is the same with (...) and with (Exception &E).
Joe
try { // test for C++ exceptions
SP->ExecProc(); // execute stored procedure
}
catch (Exception &E) { // (...) causes memory leak
// handler for any C++ exception
}
Joe
try { // test for C++ exceptions
SP->ExecProc(); // execute stored procedure
}
catch (Exception &E) { // (...) causes memory leak
// handler for any C++ exception
}
-
- Posts: 38
- Joined: Wed 16 May 2007 01:12
Hello Antaeus,
I don't know how to provide that type of script. I'm using an SQL Server database developed by others, and I really know very little about databases. The exception that occurs is a "duplicate primary key" exception. Perhaps it would be adequate for you to call any stored procedure that inserts a record, but fails unless the primary key is unique. At this point, I'm assuming this is a RAD2007 issue, and not an SDAC issue.
Joe
I don't know how to provide that type of script. I'm using an SQL Server database developed by others, and I really know very little about databases. The exception that occurs is a "duplicate primary key" exception. Perhaps it would be adequate for you to call any stored procedure that inserts a record, but fails unless the primary key is unique. At this point, I'm assuming this is a RAD2007 issue, and not an SDAC issue.
Joe
Try to modify your code so that it looks like this:
Code: Select all
try
{
SP->ExecProc();
}
catch (EMSError &E) { } // <<--- the new line
catch (Exception &E) { }
}
-
- Posts: 38
- Joined: Wed 16 May 2007 01:12
-
- Posts: 38
- Joined: Wed 16 May 2007 01:12
hi antaeus,
are you saying it should not be necessary to do that to avoid the leak? if so, that's a serious bug and you should report it to codegear. i would do it myself, but i don't understand the issue well enough. if you look at the c++ builder IDE newsgroup, you'll see a "try / catch memory leak" thread, started by me, and you can reply.
thanks for your help.
joe
are you saying it should not be necessary to do that to avoid the leak? if so, that's a serious bug and you should report it to codegear. i would do it myself, but i don't understand the issue well enough. if you look at the c++ builder IDE newsgroup, you'll see a "try / catch memory leak" thread, started by me, and you can reply.
thanks for your help.
joe
-
- Posts: 38
- Joined: Wed 16 May 2007 01:12
All exceptions of the EMSError class will be handled in the first catch{} section. All other errors will be handles in the second catch{} section. Thus each error will be handled only once.
Last edited by Antaeus on Fri 01 Feb 2008 09:16, edited 1 time in total.