Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB General » View Thread |
Messages 1 to 8 of 8 total |
Can I force to free memory? |
Tue, May 18 2010 6:01 AM | Permanent Link |
gripsware gripsware datentechnik gmbh | Hi,
I create for temporary processes like printing etc. a local TEDBQuery. Run my command and free the local component at the end. e.g. var q : TEDBQuery; begin q := TEDBQuery.Create(nil); q.SessionName := MyDatabase.SessionName; q.DatabaseName := MyDatabase.DatabaseName; q.RequestSensitive := True; try q.SQL.Text := 'SELECT * FROM ADDRESS'; q.Open; ....... Do Printing here .... finally q.Free; end; end; When I call the open command there will be memory allocated by q. This memory will not be freed after I free q. 1. Why? 2. Can I force that behaviour? Thanks for help, best regards Michael |
Tue, May 18 2010 6:31 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Volker
Why do you think memory isn't being freed? Roy Lambert |
Tue, May 18 2010 7:05 AM | Permanent Link |
gripsware gripsware datentechnik gmbh | Hello Roy,
I check the using of the memory with Process Explorer while I step trough my printing process. I see that memory using increase at the Open or ExecSQL line, but still hold the memory usage after the Free command. So I think, memory isn´t beeing freed. Do you not think so? BTW I develop with BDS2006 Win32 app, Elevate DB 2.03.13 Thanks Michael Roy Lambert wrote: Volker Why do you think memory isn't being freed? Roy Lambert |
Tue, May 18 2010 7:46 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Volker
Its almost certainly down to timing. Windows doesn't free up memory as soon as an application releases it, and may often leave it sitting there. The best way to find out if memory is being leaked is to use the facilities in FastMM or some other memory checker. Believe me if ElevateDB was leaking memory with every query created there would be a LOT of angry customers shouting at Tim. Roy Lambert |
Tue, May 18 2010 8:08 AM | Permanent Link |
gripsware gripsware datentechnik gmbh | Roy,
but if I create an TBitmap and load a picture to that and free this at the end of my operation, then I see immediately that the memory is freed. I think not that elevateDB has memory leaks, because the memory is freed when I close the application. I think elevateDB holds cache buffers or something else when I run a query. And this buffers will be freed on closing the connection. BTW I will try the FastMM features to search for leaks. Thanks for your help Michael |
Tue, May 18 2010 4:06 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Volker,
<< When I call the open command there will be memory allocated by q. This memory will not be freed after I free q. 1. Why? >> Do you have the ADDRESS table open elsewhere in your application ? If so, then ElevateDB will internally keep the physical table (and any cache buffers loaded for it for rows, index pages, BLOB blocks, etc.) until all references (TEDBTable, TEDBQuery, etc.) to the physical table are gone. << 2. Can I force that behaviour? >> Yes, just close the TEDBDatabase component and that will force all internal table structures to be discarded by ElevateDB. Is there any particular reason that you're worried about (what should amount to) several hundred KB of memory ? -- Tim Young Elevate Software www.elevatesoft.com |
Wed, May 19 2010 3:40 AM | Permanent Link |
gripsware gripsware datentechnik gmbh | Tim,
<<Do you have the ADDRESS table open elsewhere in your application ? If so, then ElevateDB will internally keep the physical table (and any cache buffers loaded for it for rows, index pages, BLOB blocks, etc.) until all references (TEDBTable, TEDBQuery, etc.) to the physical table are gone.>> In that case when I do a query on a single table, yes! But most of my queries joins tables together, so there is no exact table matching. <<Yes, just close the TEDBDatabase component and that will force all internal table structures to be discarded by ElevateDB.>> I read that in documentation, and so I create a second TEDBDatabase for that temporary queries. I connect this TEDBDatabase to the same Session Component as my MainDBDatabase. But when I close the Database after my printing process there is still no change in memory consuption. <<Is there any particular reason that you're worried about (what should amount to) several hundred KB of memory ?>> When I start my application it uses 80.000kB of memory. A large part was the visual components (SkinLibrary of DevExpress). When I browse through application then uses each query additional memory, and I came never back to these 80.000kB. Especially printing, there was a lot of queries to find the needed informations. There are also pictures and large text blocks in blob and clob fields. When I start app I need 80.000kB of memory, go immediately to printing and print a large report the memory increases to 94.000kB while I´m in preview, and goes back to 93.000kB when I close preview. So if I browse through my app it´s no problem to bring memory to 170.000kB, but never back. When I learned programming it was normal to give back what I had taken (<- bad english, sorry) as soon as possible. So I have a lot of try..finally blocks in my application to release the resources after use. I use a function to create my temp used queries: function CreateQuery(OnDatabase: TEDBDatabase): TEDBQuery; begin Result := TEDBQuery.Create(nil); if OnDatabase = nil then begin FTempDB := FEDBSession.FindDatabase('TempDB'); if FTempDB = nil then begin FTempDB := TEDBDatabase.Create(Self); FTempDB.Temporary := True; FTempDB.DatabaseName := 'TempDB'; FTempDB.Database := FEDBDatabase.Database; FTempDB.KeepConnection := False; FTempDB.SessionName := FEDBDatabase.SessionName; FEDBSession.OpenDatabase('TempDB'); end; OnDatabase := FTempDB; end; Result.SessionName := OnDatabase.SessionName; Result.DatabaseName := OnDatabase.DatabaseName; Result.RequestSensitive := True; end; The first call creates the FTempDB, and any further call uses this FTempDB. At the end of my operation I free all my created queries and call then FTempDB.Close. But memory is not freed . Hope you can help, best regards Michael Please don´t call me Volker, the elevate components was registered to Volker, but I work with them |
Wed, May 19 2010 7:19 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Michael (sorry about Volker ,
<< I read that in documentation, and so I create a second TEDBDatabase for that temporary queries. I connect this TEDBDatabase to the same Session Component as my MainDBDatabase. But when I close the Database after my printing process there is still no change in memory consuption. >> TEDBDatabase components are just "shells" around the internal engine objects, so using a temporary TEDBDatabase component won't really affect anything in terms of the engine memory allocations if the database or any of the tables are open elsewhere in your application. Also, there is a good chance that the memory manager may keep blocks of memory around because they are sub-allocations from larger blocks of allocated memory. << When I start my application it uses 80.000kB of memory. A large part was the visual components (SkinLibrary of DevExpress). When I browse through application then uses each query additional memory, and I came never back to these 80.000kB. Especially printing, there was a lot of queries to find the needed informations. There are also pictures and large text blocks in blob and clob fields. When I start app I need 80.000kB of memory, go immediately to printing and print a large report the memory increases to 94.000kB while I´m in preview, and goes back to 93.000kB when I close preview. So if I browse through my app it´s no problem to bring memory to 170.000kB, but never back. When I learned programming it was normal to give back what I had taken (<- bad english, sorry) as soon as possible. So I have a lot of try..finally blocks in my application to release the resources after use. >> Are you using the ElevateDB Server ? If so, then you can see exactly what tables are open, and how much memory is being used for buffering the table contents, by quering this table: http://www.elevatesoft.com/manual?action=viewtopic&id=edb2sql&topic=ServerSessionStatistics_Table That may help shed some light on what is going on. I can assure you that ElevateDB is releasing memory as soon as it is no longer necessary, but it may involve closing databases/tables/queries that you currently have open. -- Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Tuesday, April 30, 2024 at 03:55 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |