limelect 48 Posted December 13, 2022 @Dalija Prasnikar That is the time to say "Don't use memory stream to load data to rich edit. Create temporary file and write the data into that file and then load the data from the filestream." I tried all ready weeks ago Share this post Link to post
Anders Melander 1783 Posted December 13, 2022 This whole thread is a big waste of everyone's time, including the OP. There's no point in trying to come up with alternate solutions when it seems no real attempt has been made to locate and isolate the cause of the problem. Run your application in the debugger. When the out-of-memory occurs, look at the call stack and place a breakpoint somewhere up the call stack before the call to the lower level method. Reset the debug session and run again. When the breakpoint is hit, single-step into the methods below, watch the memory consumption and try to understand what's going on in the code. At some point, you will likely arrive at the location where too much memory is allocated and the cause and/or solution will present itself. I do have a hunch about what the problem is, but it's no better than all the other guesses when the basic troubleshooting hasn't been done. 5 Share this post Link to post
limelect 48 Posted December 13, 2022 Crazy as it sounds I executed my main program Then concurrent I executed my TEST program which it does read this record into richedit. Well, both programs are in memory and it worked on my test program. However, twice the DB as I did not want a lock condition. Just to check the loading of the record Share this post Link to post
limelect 48 Posted December 13, 2022 @Anders Melander I answered that way of thinking. Your proposal is too basic Share this post Link to post
programmerdelphi2k 237 Posted December 13, 2022 I have to agree with "Melander"... unfortunately, the topic should have another title: Please dont help, I dont need! Finally, I didn't attack anyone, I just reported what happened, and I can prove it with emails and "private message"! I'm sorry I couldn't help but in fact the applicant doesn't give us the chance to help and postpones using the "possible solutions" sent to him! Without further ado, I, as "Frost.Brutal" also give up and say that I will not respond to possible future attacks! luck! Share this post Link to post
programmerdelphi2k 237 Posted December 13, 2022 here is the project that "HE" send me! NOTE: anyone can see that it's a terrible project (same that for tests) TestMyDataBase.zip Share this post Link to post
programmerdelphi2k 237 Posted December 13, 2022 On 12/9/2022 at 2:03 PM, limelect said: @programmerdelphi2k I do not believe your solution did it.But it did also, it is on my test program I now will move to my main program MyMemStream:= ProjectsFDTable.CreateBlobStream(ProjectsFDTable.FieldByName('Description'),bmRead); AdvRichEditor.BeginUpdate; AdvRichEditor.LoadFromStream(MyMemStream); AdvRichEditor.EndUpdate Share this post Link to post
Dalija Prasnikar 1396 Posted December 13, 2022 30 minutes ago, limelect said: "Don't use memory stream to load data to rich edit. Create temporary file and write the data into that file and then load the data from the filestream." I tried all ready weeks ago The question is whether or not you have done that correctly. The moment you write the data to file, you need to release memory of all the temporary data that was used in that process before you try to load that into control. MyMemStream := ProjectsFDTable.CreateBlobStream(ProjectsFDTable.FieldByName('Description'),bmRead); try TMemoryStream(MyMemStream).SaveToFile('t.txt'); // using absolute path is preferred finally MyMemStream.Free; end; Memo1.BeginUpdate; try Memo1.LoadFromFile('t.txt'); finally Memo1.EndUpdate; end; 1 Share this post Link to post
programmerdelphi2k 237 Posted December 13, 2022 I have this "tech" in a project where I can read a file with +6GBytes (in disk), and each read (buffer) can have any size, since that < "file-Size" and < memory-avaliable (obviously, we must be sensible here and not overdo it at this point)! I start with Buffer of 32MBytes... read, work it, save and go ahead!!! all operations works on "bytes" processing... reading bytes, changing values, saving bytes! < 2minutes! < 4GBytes RAM on max data-charge (normally, 1GB is enough) Share this post Link to post
limelect 48 Posted December 13, 2022 (edited) @Dalija Prasnikar see in one of my answers I even free all used components DB and link nothing helped. Once the program reaches max memory nothing helps But if I use 2 programs just for testing see above it works. Even on the same DB Edited December 13, 2022 by limelect Share this post Link to post
Dalija Prasnikar 1396 Posted December 13, 2022 5 minutes ago, limelect said: @Dalija Prasnikar see in one of my answers I even free all used components DB and link nothing helped. Once the program reaches max memory nothing helps But if I use 2 programs just for testing see above it works. Even on the same DB Then the problem is not in this particular code but all the other code that consumes all available memory. The general advice for reducing memory footprint I gave earlier still stand. Yes, using separate applications will help because each will have its own memory limit if they are running on 64-bit OS. Share this post Link to post
limelect 48 Posted December 13, 2022 @Dalija Prasnikar what bugs me is that my form creat does nothing except for open DB and show it in the grid. However, I also read my text file on my server for version notification and this should not take almost no memory. I will keep checking Thanks Share this post Link to post
limelect 48 Posted December 13, 2022 (edited) OK everybody first THANKS LASTLY, I hope no one is angry at me. And this made memory almost still I added a ValidateDB. from the Internet function ValidateDB : String; var goodsqlitedb : Boolean; FDPhysSQLiteDriverLink2 : TFDPhysSQLiteDriverLink; FDSQLiteValidate2 : TFDSQLiteValidate; FDPhysDriverService : TFDPhysDriverService; FDSQLiteSec2 : TFDSQLiteSecurity; begin Result := 'Undefined'; try goodsqlitedb:=true; Form1.ListBox1.Items.Clear; //FDSqliteConn.Open; FDPhysSQLiteDriverLink2:=TFDPhysSQLiteDriverLink.Create(nil); FDSQLiteValidate2:=TFDSQLiteValidate.Create(nil); FDPhysDriverService:=TFDPhysDriverService.Create(nil); FDSQLiteSec2:=TFDSQLiteSecurity.Create(nil); FDSQLiteSec2.DriverLink := FDPhysSQLiteDriverLink2; FDSQLiteValidate2.DriverLink:=FDPhysSQLiteDriverLink2; //FDSQLiteValidate2.OnProgress(FDPhysDriverService,DBMessage); // "with" is evil, so omit it // with FDSQLiteValidate2 do begin updatelog( 'To Start the Validation'); FDSQLiteValidate2.Database := 'Applications.db'; FDSQLiteValidate2.Analyze; updatelog('Database To be Analyzed'); if not FDSQLiteValidate2.CheckOnly then Result:= '1' //Database has problems else Result:= '0'; //Database is good //end; except on E: Exception do begin updatelog( 'Database Exception='+E.Message); Result:= '2'; //Database is Corrupt goodsqlitedb := False; //raise; end; end; try FDPhysSQLiteDriverLink2.Destroy; FDSQLiteValidate2.Destroy; FDPhysDriverService.Destroy; FDSQLiteSec2.Destroy; finally updatelog( 'Drivers destroyed'); end; end; Now, memory stays almost the same while searching. One problem my special record now takes almost 5!! minutes to load. Edited December 13, 2022 by limelect Share this post Link to post
programmerdelphi2k 237 Posted December 13, 2022 Certainly, no anger! Just listen to your heart, and when possible all those who want to help you in some way! As I said, it was just using a tool to "check / validate" your DB, right from the start! Share this post Link to post