Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.
Experiencing memory leak using SRP_Com (probably self-inflicted)
We are prepping/testing our 9.4 OI installation for 10.x. We recently realized we no longer had access to XOInstance() :) .. so we decided to check out SRP_Com(). I'm new to ADODB so expect our problem to be some step I've neglected. We are processing thousands of OI data table records and for each record creating a SQL insert query. Our process looks something like this ...
If SRP_Com(obj_connection, 'CREATE', 'ADODB.Connection') then
SRP_Com(obj_connection, 'call', 'Open', connection_string)
err_msg = SRP_Com('', 'ERROR')
If err_msg Ne '' Then err_msg = "Error creating a connection. " : err_msg
End Else
err_msg = "Unable to create ADODB.Connection object. " : err_msg
End
--- Loop through OI records .. readnext @ID .. etc. ---
query = "insert into table_name (f1, f2, f3, ... fn) values (OI record values for each field)"
obj_recordset = SRP_Com(obj_connection, 'Call', 'Execute', query)
err_msg = SRP_Com('', 'Error')
if err_msg ne '' then
... handle errors
end
--- Repeat ---
I just tried putting the line ... SRP_Com(obj_recordset, 'Call', 'Release') ... inside the loop directly above the --- Repeat --- line but the memory usage still builds throughout the loop.
Thanks for your time.
If SRP_Com(obj_connection, 'CREATE', 'ADODB.Connection') then
SRP_Com(obj_connection, 'call', 'Open', connection_string)
err_msg = SRP_Com('', 'ERROR')
If err_msg Ne '' Then err_msg = "Error creating a connection. " : err_msg
End Else
err_msg = "Unable to create ADODB.Connection object. " : err_msg
End
--- Loop through OI records .. readnext @ID .. etc. ---
query = "insert into table_name (f1, f2, f3, ... fn) values (OI record values for each field)"
obj_recordset = SRP_Com(obj_connection, 'Call', 'Execute', query)
err_msg = SRP_Com('', 'Error')
if err_msg ne '' then
... handle errors
end
--- Repeat ---
I just tried putting the line ... SRP_Com(obj_recordset, 'Call', 'Release') ... inside the loop directly above the --- Repeat --- line but the memory usage still builds throughout the loop.
Thanks for your time.
Comments
SRP_Com(obj_recordset, 'Release') .. which didn't help the memory usage, i just added ...
obj_recordset = '' ... which also did not help :) .... argh ...
SRP_Com(obj_recordset, "RELEASE")
Otherwise, those objects stay in memory. You'll also want to release the obj_connection object when you're done with your loop.
much appreciated!