Aurelius memory problems

I am developing an application that has to take hundreds of files and insert their content into a database.
I developed everything using Aurelius which allows me to easily manage various types of DB. The application seems to work fine until the amount of data to import becomes important. When there are many data to be imported, the application crashes, because the allocated memory becomes too high. The problem seems to depend on the way in which Aurelius manages the data, in the sense that even after a SAVE and a FLUSH it seems that Aurelius still holds data in his stomach, checking with a resource manager it is very clear that as the procedure proceeds, the allocated memory becomes higher and higher, if the system manages to get to the end then the memory is deallocated and everything returns as before, but if it grows too much the program crashes.
From what I have read, I think I understand, that after a FLUSH Aurelius consolidates the operations performed on the DB, this is enough or other procedures must also be done to free memory!

The update part is performed in this way, TDB_DATAROWS represents my table, FDB_Manager is an Aurelius TObjectManager, the main program pass to the procedure, which runs in a secondary thread, the data related to one file, the program creates the TDB_DATAROWS object sets the properties and stores everything.
As I said before, if the procedure manages to finish, all the data is correctly saved, and even if it crashes I still find data loaded!

  Data:=TDB_DATAROWS.Create;
  try

// here I fill Data with real data taken from files

    FDB_Manager.Save(Data);
    FDB_Manager.Flush(Data);
  finally
     Data.free;
  end;

Thanks
Lorenzo

Hi there,

AFAIU you don't need to keep hold of the inserted objects, so just tell the ObjectManager that:

FDB_Manager := TObjectManager.Create;
FDB_Manager.OwnsObjects := False
{...}

Also, AFAIK, Flush should be used only when UPDATING managed objects.

HTH

1 Like

Yes FDB_Manager.OwnsObjects: = False is set during creation, sorry but I didn't report it here. What is not clear to me was if I should use FLUSH or not, initially I did not use it, then I entered it to understand if the memory problems depended on that.

1 Like

You don't need to call Flush in this case, just to insert objects Save is enough.
What you can do is call Clear to clear the manager from time to time and release memory. If you don't do it, indeed, all the objects you created are kept in manager cache.

2 Likes

This solves the problem!
Thank you!

Lorenzo

1 Like

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.