July 31, 20205 yr Hi Guys, i know that this isn't a specific question about FGX but i try to ask you. I attach a little demo source code that i'm writing. I'm using a DrawerLayout and i show differents forms in the Content. All works perfectly. When i've to destroy the Form i've seen in your Demo that i've to write the rows below : MyForm.Parent := nil; FreeAndNil(MyForm); If i do that, it works perfectly, but, if i comment the "MyForm.Parent := nil" and i call only FreeAndNil, for Delphi MyForm is destroyed but for Android no, because i can see it in my content and i can work with it. I know that Java use the Garbage Collector so i'm worried about "Free Form Memory". In Delphi, if i seen MyForm = nil i will create it another time so, how many MyForm i've in memory ? I've a second question, not so important, but i try to ask: My TFrameUsers load data from a Rest Service into a CollectionView. I know that i can write better code, but i see that if i try to scroll the CollectionView, it is slow in the first 2 seconds, and then it is very fast! I can't understand why it is slow at the beginning... I'm sure that all data is available so, do you have any idea in "Why it is slow at the begin?" Many Thanks guys. Demo01.zip
July 31, 20205 yr Hello, imho in new version Delphi, it have own garbage collector, and you don't worry about memory leaks, about you second question, can you try load you rest data locally from inner json and compare time for loading Thanks Edited July 31, 20205 yr by Stas
August 1, 20205 yr Hi, Rad Studio 10.3 memory manager uses arc on mobile, so you kind of shouldnt dont worry about memory release. On 10.4 on mobile now use standard memory model(not more arc) and you SHOULD be aware to release memory. About second question, not quite familiar with TRestRequest class and ExecuteAsync Method, In my own experience i always do any intenert request using Threads with no problems(no delays on main thread). I would suggest to use Threads to request data from the internet. I'm developing a App that laods data and images from a rest server with no delay on the app using threads. Hope it Helps, Omar Zelaya
August 1, 20205 yr Hi Maybe this help, procedure CustomThread( AOnStart, AOnProcess, AOnComplete : TProc; AOnError: TProcedureExcept; ADoCompletWithError: Boolean = True); var LThread : TThread; begin LThread := TThread.CreateAnonymousThread( procedure () var LDoComplete : Boolean; begin try try //OnStart LDoComplete := True; if Assigned(AOnStart) then begin TThread.Synchronize( TThread.CurrentThread, procedure () begin AOnStart; end ); end; //OnProcess if Assigned(AOnProcess) then AOnProcess; //OnError except on E:Exception do begin LDoComplete := ADoCompletWithError; if Assigned(AOnError) then begin TThread.Synchronize( TThread.CurrentThread, procedure () begin AOnError(E.Message); end ); end; end; end; finally //OnComplete if Assigned(AOnComplete) then begin TThread.Synchronize( TThread.CurrentThread, procedure () begin AOnComplete; end ); end; end; end ); LThread.FreeOnTerminate := True; LThread.Start; end;
August 1, 20205 yr Author Hi Omar, Many thanks for your support. I will check your source code for a better management. However in my case the problem is not read data. I attach a small video. I can wait 20 or 30 seconds before start the scolling and data is already stored in my collection. As you can see the lag is very very small and it isn't a problem but i'm trying to get best practice methods and discover what can't be solved and what is a limit. Many Thanks. V_20200801_131036.mp4
August 1, 20205 yr Hi, usage of thread method. CustomThread(/// OnStart procedure () begin // show some kind of wait message to user end, /// OnProcess procedure () begin // request data end, /// On Complete procedure () begin /// show end data request end, // On Error procedure () begin /// show error on data request end);
Create an account or sign in to comment