Zeos DB on Oracle: Memory Leak lazarus / 16-Databases ---------------------------------------------------------------------- tiagorocha · 2012-11-20 19:36 Hi! First, version info: Lazarus: 0.9.30.4 32bit FPC: 2.6.0 Workstation is Windows 7 64 bit Server is Windows 2008 64bit ZeosDB: 6.6.6 Oracle: 11.2.0.2 SE Issue: I'm facing memory leaks with Zeos. I have an application that is required to send a heartbeat (ping) to a server. This application has a timer component and when timer is due, it calls a Zeos TZSQLProcessor component, that has a stored procedure on an Oracle database. It works. I'm using Zeos because I wasn't able to call a stored procedure with other components. Anyway, app keeps growing memory usage until it eats all the server memory and stop working properly, gets slow and start missing jobs. I ran Leak Test: Code: [Select]Heap dump by heaptrc unit 20551 memory blocks allocated : 17750624/17906800 18261 memory blocks freed     : 16972823/17123888 2290 unfreed memory blocks : 777801 True heap size : 1671168 (80 used in System startup) True free heap : 707264 Should be : 741616 Call trace for block $00281190 size 49   $005C4BEC  TZSQLPROCESSOR__PARSE,  line 429 of C:/lazarus/components/zeosdb/src/component/ZSqlProcessor.pas   $005C4885  TZSQLPROCESSOR__EXECUTE,  line 373 of C:/lazarus/components/zeosdb/src/component/ZSqlProcessor.pas   $004278B9  TFRMGATEOPS__TMRHEARTBEATTIMER,  line 471 of unit1.pas   $00500BA5  TCUSTOMTIMER__DOONTIMER,  line 181 of customtimer.pas   $00500B0F  TCUSTOMTIMER__TIMER,  line 156 of customtimer.pas   $00509615  TIMERCALLBACKPROC,  line 2710 of win32callback.inc   $75F362FA   $75F37B16 Any suggestion? Regards, Tiago leaky memory software engineer ---------------------------------------------------------------------- EgonHugeist · 2012-11-20 22:07 Zeos7 ? don't trust in Beta-state. We're FPC stable. Also did we make a run with heap-tracing and AFAIK there are no more leaks to expect on Zeos7. Also did we made a complete makeover for the TZStoredProc component. You can use this one instead. For MySQL do we support multiple ResultSets/DataSets too. Only thing i know which we do not support for Oracle is Notify or NestedDataSet columns because we've no ide how to get it running with FPC (Delphi supports it since Delphi6). I think this will sove your issue. On the other hand -> Zeos-Forum Regards ---------------------------------------------------------------------- tiagorocha · 2012-11-21 10:52 Hi EgonHugeist,   I'm using Zeos 6.6.6, not 7. Think I should upgrade? Isn't 7 still beta version?   Will try TZStoredProc and will report back. Thanks for the help! Regards, Tiago ---------------------------------------------------------------------- BigChimp · 2012-11-21 11:58 Yes, EgonHugeist is saying you should upgrade to 7. ---------------------------------------------------------------------- tiagorocha · 2012-11-21 17:12 Hi BigChimp, thanks for clarifying. I figured I needed 7.x as soon as I got an "unsupported" message... anyway, TZStoredProc on 7 is quite a bit slower than TZSQLProcessor on 6 and the memory leak only got worse (trace below). I'm tinkering a little bit more and will let you know. This is a 24x7 industrial type mission critical application I'm developing. It *has* to work flawlessly and unattended. Think I should head over Zeos Forum? Thank you! Regards, Tiago Code: [Select]c:\sistema\gateops\GateOps.exe Heap dump by heaptrc unit 26498 memory blocks allocated : 12263630/12323080 7824 memory blocks freed     : 3097209/3118272 18674 unfreed memory blocks : 9166421 True heap size : 12189696 (96 used in System startup) True free heap : 1497008 Should be : 1789656 Call trace for block $080C8280 size 53256   $006BCCFD  TZORACLECALLABLESTATEMENT__PREPARE,  line 730 of C:/lazarus/components/Zeos7/src/dbc/ZDbcOracleStatement.pas   $006BD871  TZORACLECALLABLESTATEMENT__EXECUTEUPDATEPREPARED,  line 918 of C:/lazarus/components/Zeos7/src/dbc/ZDbcOracleStatement.pas   $006DE35F  TZABSTRACTRODATASET__EXECSQL,  line 1564 of C:/lazarus/components/Zeos7/src/component/ZAbstractRODataset.pas   $005C4753  TZSTOREDPROC__EXECPROC,  line 361 of C:/lazarus/components/Zeos7/src/component/ZStoredProcedure.pas   $00427B87  TFRMGATEOPS__TMRHEARTBEATTIMER,  line 506 of unit1.pas   $00501715  TCUSTOMTIMER__DOONTIMER,  line 181 of customtimer.pas   $0050167F  TCUSTOMTIMER__TIMER,  line 156 of customtimer.pas   $0050A185  TIMERCALLBACKPROC,  line 2710 of win32callback.inc Call trace for block $0815A910 size 16   $0040E3C8   $0062275A  TZCOLLECTION__GROW,  line 304 of C:/lazarus/components/Zeos7/src/core/ZCollections.pas   $006229DE  TZCOLLECTION__ADD,  line 379 of C:/lazarus/components/Zeos7/src/core/ZCollections.pas   $00623D1E  TZHASHMAP__PUT,  line 939 of C:/lazarus/components/Zeos7/src/core/ZCollections.pas   $0062D8D5  TZABSTRACTDATABASEMETADATA__ADDRESULTSETTOCACHE,  line 1868 of C:/lazarus/components/Zeos7/src/dbc/ZDbcMetadata.pas   $0062E4AD  TZABSTRACTDATABASEMETADATA__GETPROCEDURECOLUMNS,  line 2192 of C:/lazarus/components/Zeos7/src/dbc/ZDbcMetadata.pas   $005C44C8  TZSTOREDPROC__SETSTOREDPROCNAME,  line 331 of C:/lazarus/components/Zeos7/src/component/ZStoredProcedure.pas   $00427B79  TFRMGATEOPS__TMRHEARTBEATTIMER,  line 505 of unit1.pas ---------------------------------------------------------------------- BigChimp · 2012-11-21 17:22 Well, that's what the man said. ---------------------------------------------------------------------- tiagorocha · 2012-11-21 18:26 Fixed. Solution: Don't use DumpHeap in the middle of your software. Memory usage is still increasing though... Weird. Let's fiddle more. Regards, Tiago Code: [Select]C:\GateOps\GateOps.exe Heap dump by heaptrc unit 26092 memory blocks allocated : 39560412/39619736 26092 memory blocks freed     : 39560412/39619736 0 unfreed memory blocks : 0 True heap size : 2359296 (80 used in System startup) True free heap : 2359584 Should be : 2359216