Paging results

Hi!

Okay so this is what I am doing currently:

var
  ResultData: TVisiteDynResult;
  ORM: TObjectList<TSSTPERSONALE_VISITE>;
  ORMVisita: TSSTPERSONALE_VISITE;
  CountResult: TCriteria;

Then in the code:

if start  = 0  then
      begin
        CountResult := ObjectManager.Find<TSSTPERSONALE_VISITE>.Select(TProjections.Sql<Int64>('Count(*)')).Clone;
        CountResult.AutoDestroy := False;
        ResultData.total_count := CountResult.UniqueValue.Values[0];
      end;

And then releasing it in my finally. Unfortunately, I am still having memory leaks, so I am certain something isn't quite right. The remainder works as intended so the problem is here, in how I get and use the count.

Any ideas?

Thanks!