I'm using part of a code sample found in the sample file SnpExportDynamicDocument.cpp that goes:
ErrorCode SnpExportDynamicDocument::ExportSWF(const UIDRef & documentUIDRef, IDFile& swfFileName)
{
ErrorCode status = kFailure;
InterfacePtr<IPMStream> outStream(StreamUtil::CreateFileStreamWriteLazy(swfFileName, kOpenOut | kOpenTrunc));
SDKFileHelper fileHelper(swfFileName);
if (fileHelper.GetPath().empty())
{
ASSERT_FAIL("Invalid or missing filename.");
return kFailure;
}
// create the SWF export action command
InterfacePtr<ICommand> swfExportCmd(CmdUtils::CreateCommand(kSWFExportCommandBoss));
if (swfExportCmd == nil)
{
ASSERT(swfExportCmd);
return kFailure;;
}
// Set Target
UIDList items(documentUIDRef.GetDataBase());
InterfacePtr<IPageList const> pageList(documentUIDRef, UseDefaultIID());
for (int32 pageIndex = 0, pageCount = pageList->GetPageCount(); pageIndex < pageCount; ++pageIndex)
items.Append(pageList->GetNthPageUID(pageIndex));
swfExportCmd->SetItemList(items);
// Set cmd data
// IID_IDYNDOCSEXPORTCOMMANDDATA
InterfacePtr<IDynamicDocumentsExportCommandData> dynamicDocsCmdData(swfExportCmd, UseDefaultIID());
dynamicDocsCmdData->SetStream(outStream);
dynamicDocsCmdData->SetUIFlags(kSuppressUI);
// IID_ISWFEXPORTPREFERENCES
InterfacePtr<ISWFExportPreferences> swfCmdData(swfExportCmd, UseDefaultIID());
InterfacePtr<IWorkspace> iAppWS(GetExecutionContextSession()->QueryWorkspace());
InterfacePtr<ISWFExportPreferences> iSWFExportPrefs(iAppWS, UseDefaultIID());
swfCmdData->Copy(iSWFExportPrefs);
// process the command
return CmdUtils::ProcessCommand(swfExportCmd);
}
It leaks on the very last line. That is, if I remove the ProcessCommand() then there's no memory leak.
There appear to be "2 leaks, 130072 bytes" leaked every time I call the above.
I'm just pasting sample code that comes with CS6 SDK, so I can't see what the problem is.
I've checked the code in
Any suggestions?