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)

edited May 2023 in SRP Utilities
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.

Comments

  • edited May 2023
    so at the end of (inside of) the loop we put ...

    SRP_Com(obj_recordset, 'Release') .. which didn't help the memory usage, i just added ...
    obj_recordset = '' ... which also did not help :) .... argh ...
  • You need to call RELEASE on any object that you acquire from the CREATE service or from calling a method. In your case, you need to this when you are done with each record set object:

    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.
  • Thanks Kevin, I did add that 'Release' command for the recordset, but not for the connection object. I'll try that now.
  • That should definitely help. In our early efforts to do what you are doing we discovered these "memory leaks" after running our code for extended periods of time. I think the sample code I included in this blog post does a proper release of each object.
  • Thank you fellas! So after adding the Release command it WOULD have worked if I used the correct syntax in the command :) .... over 10,000 records now and no further memory usage.

    much appreciated!
Sign In or Register to comment.