Re: ADO high virtual memory usage
- From: Gareth Hopkins <GarethHopkins@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 21 Mar 2007 03:21:13 -0700
Hi
Please find the source unit below. It is pretty simple so would easily be
translated to VC++ I guess. In Delphi we also use Smart pointers ie when refs
go out of scope or are set to nil then the object is automatically
dereferenced etc + when are created they are auto addrefed...
It would be interesting to see if your test exe shows the same behaviour as
mine.
Thanks
Gareth
-----------Source-----------
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
btnCreate: TButton;
btnRelease: TButton;
procedure btnCreateClick(Sender: TObject);
procedure btnReleaseClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses ADODB_TLB;
{$R *.dfm}
var
arr: array[0..1000] of _recordset;
procedure TForm1.btnCreateClick(Sender: TObject);
var
rs:_recordset;
x, i: integer;
begin
for x := 0 to 1000 do
begin
rs := CoRecordset.Create;
rs.Fields._Append('test', adInteger, 0, adFldIsNullable);
rs.Open(EmptyParam, EmptyParam, adOpenStatic, adLockBatchOptimistic,
adCmdUnknown);;
for i := 0 to 1000 do
begin
rs.AddNew(EmptyParam, EmptyParam);
rs.Fields['test'].Value := 100;
end;
rs.updatebatch(adAffectAll);
arr[x] := rs;
end;
end;
procedure TForm1.btnReleaseClick(Sender: TObject);
var
x: integer;
begin
for x := 0 to 1000 do
begin
if assigned(arr[x]) then
begin
arr[x].Close;
// arr[x]._Release;
arr[x] := nil;
end;
end;
end;
end.
.
- Follow-Ups:
- Re: ADO high virtual memory usage
- From: Bob Barrows [MVP]
- Re: ADO high virtual memory usage
- From: Ralph
- Re: ADO high virtual memory usage
- References:
- Re: ADO high virtual memory usage
- From: Stephen Howe
- Re: ADO high virtual memory usage
- From: Stephen Howe
- Re: ADO high virtual memory usage
- From: Stephen Howe
- Re: ADO high virtual memory usage
- Prev by Date: Re: Just another SQL Query
- Next by Date: Re: Defect ADO library VBScript??
- Previous by thread: Re: ADO high virtual memory usage
- Next by thread: Re: ADO high virtual memory usage
- Index(es):