Last active
August 29, 2015 13:58
-
-
Save stijnsanders/9960826 to your computer and use it in GitHub Desktop.
SSCCE about reference counting of TStreamAdapter's
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unit SSCCE_arc; | |
//see also http://stackoverflow.com/questions/22846335/why-is-this-tstreamadapter-not-released | |
interface | |
procedure SSCCE_arc1; | |
implementation | |
uses bsonDoc, SysUtils, Classes, Variants, ActiveX; | |
procedure SSCCE_arc1; | |
var | |
d:IBSONDocument; | |
x:IStream; | |
begin | |
d:=BSON(['test',VarArrayOf([ | |
BSON(['x',1]), | |
BSON(['x',2]), | |
BSON(['x',3]) | |
])]); | |
{ | |
(d as IPersistStream).Save( | |
TStreamAdapter.Create( | |
TFileStream.Create('test.bson',fmCreate),soOwned),true); | |
(d as IPersistStream).Load( | |
TStreamAdapter.Create( | |
TFileStream.Create('test.bson',fmOpenRead),soOwned)); | |
} | |
x:= | |
TStreamAdapter.Create( | |
TFileStream.Create('test.bson',fmCreate),soOwned); | |
(d as IPersistStream).Save(x,true); | |
x:=nil; | |
x:=TStreamAdapter.Create( | |
TFileStream.Create('test.bson',fmOpenRead),soOwned); | |
(d as IPersistStream).Load(x); | |
x:=nil; | |
end; | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment