#1  
Old 26th March 2012, 04:20 AM
Andreas Schachtner Andreas Schachtner is offline
Junior Member
 
Join Date: Jul 2009
Posts: 11
Default MemoryLeak in nxQuery?

Since a great Refactoring-Session and Update to NEXUSDB 3.1004 i get MemoryLeaks (ReportMemoryLeaksOnShutDown:=true) in my App.
I use only the embedded Mode of the NexusDb and
i can reproduce this with a little App like this....

unit Unit3;

interface

uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, nxseAutoComponent,
nxsrSqlEngineBase, nxsqlEngine, nxsdServerEngine, nxsrServerEngine, nxdb,
nxllComponent;

type
TForm3 = class(TForm)
nxDatabase1: TnxDatabase;
nxSession1: TnxSession;
nxServerEngine1: TnxServerEngine;
nxSqlEngine1: TnxSqlEngine;
nxseAllEngines1: TnxseAllEngines;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;

var
Form3: TForm3;

implementation

{$R *.dfm}

procedure TForm3.Button1Click(Sender: TObject);
var LQ : TnxQuery;
begin
Lq:=TnxQuery.Create(self);
try
LQ.Database:=nxDatabase1;
LQ.SQL.Text:='Select * from Plan_Kulturen';
LQ.Open;
ShowMessage (intToStr(LQ.RecordCount));
LQ.Close;
finally
LQ.Free;
end;
end;

end.


The leaks all come from Unicode Strings. Any suggestions ?
  #2  
Old 26th March 2012, 06:50 AM
Brian Evans [NDX]
 
Posts: n/a
Default Re: MemoryLeak in nxQuery?

On 25/03/2012 12:20 PM, Andreas Schachtner wrote:
> Since a great Refactoring-Session _*and*_ Update to NEXUSDB 3.1004 i get
> MemoryLeaks (ReportMemoryLeaksOnShutDown:=true) in my App.
> I use only the embedded Mode of the NexusDb and
> i can reproduce this with a little App like this....


> procedure TForm3.Button1Click(Sender: TObject);
> var LQ : TnxQuery;
> begin
> Lq:=TnxQuery.Create(self);
> try
> LQ.Database:=nxDatabase1;
> LQ.SQL.Text:='Select * from Plan_Kulturen';
> LQ.Open;
> ShowMessage (intToStr(LQ.RecordCount));
> LQ.Close;
> finally
> LQ.Free;


Not sure if this is the source of the leak but either:

Create(self) with no Free (let the parent handle it).
OR
Create(nil) with the Free;

I usually do the second for any non-visual components and
the first for visual components.Long article on various reasons
to not do Create(self) with Free:
http://delphi.about.com/od/kbcurt/ss...createno_3.htm

--
Brian Evans [NDX]
Ottawa, ON, CANADA
GMT-5
  #3  
Old 26th March 2012, 04:23 PM
Andreas Schachtner Andreas Schachtner is offline
Junior Member
 
Join Date: Jul 2009
Posts: 11
Default

Usally i use TnxQuery.Create (nil). Only in this snipped i try self for some reason.

But, for me same error with Create(nil) and Free;
  #4  
Old 26th March 2012, 08:16 PM
Eivind Bakkestuen [NDD]
 
Posts: n/a
Default Re: MemoryLeak in nxQuery?

> The leaks all come from Unicode Strings. Any suggestions ?

Please, tell us how many, and the size? Does it depend on the number of
queries run, or is it always the same?

--
Eivind Bakkestuen [NDD]
  #5  
Old 26th March 2012, 09:20 PM
Sue King
 
Posts: n/a
Default Re: MemoryLeak in nxQuery?

Eivind Bakkestuen [NDD] wrote:

> > The leaks all come from Unicode Strings. Any suggestions ?

>
> Please, tell us how many, and the size? Does it depend on the number
> of queries run, or is it always the same?


Hello Eivind,

I have been getting this leak. I need to do more testing and change
some timing to see if there is only ever 1 string, but I think that is
all I've seen.

I'm not sure if it is related to Andreas' leaks, but maybe it can help.

Regards
Sue



--------------------------------2012/3/26
20:14:43--------------------------------
A memory block has been leaked. The size is: 52

This block was allocated by thread 0xB48, and the stack trace (return
addresses) at the time was:
404ACE [System][@GetMem]
4079F7 [System][@NewUnicodeString]
408CBF [System][@UStrSetLength]
40BD5B [System][UTF8ToUnicodeString]
40BDC7 [System][UTF8ToString]
405E32 [System][TObject.ClassName]
59802C [nxllThread.pas][nxllThread][TnxThread.Create][409]
5A084E
[nxllKeepAliveService.pas][nxllKeepAliveService][TnxKeepAliveThread.Crea
te][134]
5A07CD
[nxllKeepAliveService.pas][nxllKeepAliveService][TnxKeepAliveQueue.Creat
e][119]
5A074B
[nxllKeepAliveService.pas][nxllKeepAliveService][nxAddKeepAlive][104]
5A41E3 [nxrpChannel.pas][nxrpChannel][TnxChannelExit.Create][203]

The block is currently used for an object of class: UnicodeString

The allocation number is: 6866

Current memory dump of 256 bytes starting at pointer address 7EE79640:
B0 04 02 00 01 00 00 00 12 00 00 00 54 00 6E 00 78 00 4B 00 65 00 65 00
70 00 41 00 6C 00 69 00
76 00 65 00 54 00 68 00 72 00 65 00 61 00 64 00 00 00 9E 1D 59 7A 80 80
00 00 00 00 C1 92 E7 7E
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 9E 1C 00 00 CE 4A 40 00
F7 79 40 00 2E 8E 40 00
C3 99 42 00 62 9F 57 00 66 9E 57 00 92 E3 5C 00 70 36 43 00 64 72 64 00
13 81 64 00 09 76 64 00
A8 08 00 00 48 0B 00 00 B1 7A 40 00 81 95 40 00 C9 94 40 00 C9 95 40 00
C9 94 40 00 A3 5F 40 00
E6 5E 40 00 AD 64 40 00 26 5F 40 00 33 5F 40 00 03 A0 57 00 26 00 00 00
B0 04 02 00 03 CB 46 85
60 62 95 00 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80
80 80 80 80 80 80 80 80
80 80 80 80 80 80 FC 34 B9 7A 80 80 80 80 80 80 80 80 80 80 80 80 80 80
00 00 00 00 01 98 E7 7E
. . . . . . . . . . . T . n . x . K . e . e .
p . A . l . i .
v . e . T . h . r . e . a . d . . . . Y z
.. . . . ~
.. . . . . . . . . . . . . . . . . . . J @ .
y @ . . @ .
B . b W . f W . \ . p 6 C . d r d .
.. d . . v d .
. . . H . . . z @ . @ . @ . @ .
@ . _ @ .
^ @ . * d @ . & _ @ . 3 _ @ . . * W . & . . .
. . . . F
` b .

4 z
.. . . . . ~

--------------------------------2012/3/26
20:14:43--------------------------------
This application has leaked memory. The small block leaks are
(excluding expected leaks registered by pointer):

37 - 52 bytes: UnicodeString x 1
--

  #6  
Old 27th March 2012, 07:03 AM
Andreas Schachtner Andreas Schachtner is offline
Junior Member
 
Join Date: Jul 2009
Posts: 11
Default

With the little App from my previous post i get for each ExecSQL

45-52 Byte Leak from UnicodeString x 2.

In my MainApp i get 37560 x 45-100 Byte from UnicodeString for a full Calculation. Not good.....
  #7  
Old 27th March 2012, 11:01 AM
Eivind Bakkestuen [NDD]
 
Posts: n/a
Default Re: MemoryLeak in nxQuery?

> With the little App from my previous post i get for each ExecSQL

Can you please log the issue in our tracker, including the source of
your testapp and database table?

--
Eivind Bakkestuen [NDD]
  #8  
Old 27th March 2012, 05:26 PM
Andreas Schachtner Andreas Schachtner is offline
Junior Member
 
Join Date: Jul 2009
Posts: 11
Default

done!
  #9  
Old 27th March 2012, 09:41 AM
Sue King
 
Posts: n/a
Default Re: MemoryLeak in nxQuery?

Sue King wrote:

Sorry, this is 3.1003

> Eivind Bakkestuen [NDD] wrote:
>
> > > The leaks all come from Unicode Strings. Any suggestions ?

> >
> > Please, tell us how many, and the size? Does it depend on the number
> > of queries run, or is it always the same?

>
> Hello Eivind,
>
> I have been getting this leak. I need to do more testing and change
> some timing to see if there is only ever 1 string, but I think that is
> all I've seen.
>
> I'm not sure if it is related to Andreas' leaks, but maybe it can
> help.
>
> Regards
> Sue
>
>
>
> --------------------------------2012/3/26
> 20:14:43--------------------------------
> A memory block has been leaked. The size is: 52
>
> This block was allocated by thread 0xB48, and the stack trace (return
> addresses) at the time was:
> 404ACE [System][@GetMem]
> 4079F7 [System][@NewUnicodeString]
> 408CBF [System][@UStrSetLength]
> 40BD5B [System][UTF8ToUnicodeString]
> 40BDC7 [System][UTF8ToString]
> 405E32 [System][TObject.ClassName]
> 59802C [nxllThread.pas][nxllThread][TnxThread.Create][409]
> 5A084E
> [nxllKeepAliveService.pas][nxllKeepAliveService][TnxKeepAliveThread.Cr
> ea te][134]
> 5A07CD
> [nxllKeepAliveService.pas][nxllKeepAliveService][TnxKeepAliveQueue.Cre
> at e][119]
> 5A074B
> [nxllKeepAliveService.pas][nxllKeepAliveService][nxAddKeepAlive][104]
> 5A41E3 [nxrpChannel.pas][nxrpChannel][TnxChannelExit.Create][203]
>
> The block is currently used for an object of class: UnicodeString
>
> The allocation number is: 6866
>
> Current memory dump of 256 bytes starting at pointer address 7EE79640:
> B0 04 02 00 01 00 00 00 12 00 00 00 54 00 6E 00 78 00 4B 00 65 00 65
> 00 70 00 41 00 6C 00 69 00
> 76 00 65 00 54 00 68 00 72 00 65 00 61 00 64 00 00 00 9E 1D 59 7A 80
> 80 00 00 00 00 C1 92 E7 7E
> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 9E 1C 00 00 CE 4A 40
> 00 F7 79 40 00 2E 8E 40 00
> C3 99 42 00 62 9F 57 00 66 9E 57 00 92 E3 5C 00 70 36 43 00 64 72 64
> 00 13 81 64 00 09 76 64 00
> A8 08 00 00 48 0B 00 00 B1 7A 40 00 81 95 40 00 C9 94 40 00 C9 95 40
> 00 C9 94 40 00 A3 5F 40 00
> E6 5E 40 00 AD 64 40 00 26 5F 40 00 33 5F 40 00 03 A0 57 00 26 00 00
> 00 B0 04 02 00 03 CB 46 85
> 60 62 95 00 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80
> 80 80 80 80 80 80 80 80 80
> 80 80 80 80 80 80 FC 34 B9 7A 80 80 80 80 80 80 80 80 80 80 80 80 80
> 80 00 00 00 00 01 98 E7 7E
> . . . . . . . . . . . T . n . x . K . e . e .
> p . A . l . i .
> v . e . T . h . r . e . a . d . . . . Y z
> . . . . ~
> . . . . . . . . . . . . . . . . . . . J @ .
> y @ . . @ .
> B . b W . f W . \ . p 6 C . d r d .
> . d . . v d .
> . . . H . . . z @ . @ . @ . @ .
> @ . _ @ .
> ^ @ . * d @ . & _ @ . 3 _ @ . . * W . & . . .
> . . . . F
> ` b .
>
> 4 z
> . . . . . ~
>
> --------------------------------2012/3/26
> 20:14:43--------------------------------
> This application has leaked memory. The small block leaks are
> (excluding expected leaks registered by pointer):
>
> 37 - 52 bytes: UnicodeString x 1




--



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
MemoryLeak with GetTableNames jprenou nexusdb.public.support 2 29th September 2009 04:02 AM
NxQuery SQL problem Andrew Sowerby nexusdb.public.support 2 19th January 2007 03:20 AM
edit sql in nxquery mpardinho nexusdb.public.support.sql 1 6th April 2006 11:52 PM
nxQuery mpardinho nexusdb.public.support 0 5th April 2006 09:08 AM
Indexes to nxQuery Pierre Demers nexusdb.public.support.sql 29 10th December 2003 05:32 AM


All times are GMT +11. The time now is 12:23 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.