查看单个帖子
旧 2009-05-06, 09:55 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】performance issue

performance issue
performance issue
hi,
iam using dwgdirect libraries to read dwg/dxf files for use in my application.
iam using exhostappservices :readfile wrapper class which first looks if the
dwg file exists in the dwgcollection defined in exhostappservices. if the
lookup fails then we read the dwg file through oddbhostappservices:
readfile method. i followed the same way to read a file as provided in the
example applications. the issue here is that when i read the file for the
first time everything is fine. but the lookup method fails to return even if we
pass the same filename. it has to return the database poionter as the file
is already once. but somehow the dwgcollection is getting destroyed.
this is a problem with smart pointer i suppose as it releazes the previous
object. so tried to use a normal ponter.
oddbdatabase* pdb = gvcs.readfile(........).get();
-> this readfile return a smart ptr.
but when tried to get model space id over this pdb it is crashing.
this is causing a performance problem if i need to read multiple dwg files.
because even if all the dwg files are read then when i need to call gvcs.readfile() again for all these, the lookup method is failing.
please do suggest sme solution ..
thanx in adv
aparna
can you show the code of your dwg cache?
vladimir
re:
oddbdatabaseptr exhostappservices::readfile(const odchar* filename,
bool ballowcpconversion, bool bpartial, oda::filesharemode shmode, const odpassword& password)
{
oddbdatabaseptr pres = m_dwgcollection.lookup(filename);
if(pres.isnull())
{
pres = oddbhostappservices::readfile(filename, ballowcpconversion, bpartial, shmode, password);
m_dwgcollection.add(pres.get());
}
return pres;
}
and this is the lookup method as given in example problem
oddbdatabase* exhostappservices:wgcollection::lookup(const odstring& keyfilename)
{
std::map<odstring, oddbdatabase*>::iterator iter = m_loadeddwgs.find(keyfilename);
if(iter!=m_loadeddwgs.end())
{
return iter->second;
}
return 0;
}
i am calling m_pmapdb = g_svcs.readfile( lpctstr(filename),
false, // ballowcpconversion
false, // bpartial
oda::ksharedenyno);
method from several places of the code.
g_vcs is defined in the code as
static odrxobjectimpl<myservices> g_svcs;
since m_pmapdb is a smart pointer it is destroying the dwgcollection.
so i tried to use a normal pointer instead of
oddbdatabase* pmapdb = g_svcs.readfile( lpctstr(filename),
false, // ballowcpconversion
false, // bpartial
oda::ksharedenyno).get();
and then if i call pmapdb->getmodelspaceid().safeopenobject()
it is crashing.
please let me know a solution for this.
thanks,
aparna
what is m_dwgcollection?
what is m_pmapdb?
as i understand, you used the code from some example? from which dd version?
anyway, m_dwgcollection should be some kind of
map: odstring->oddbdatabaseptr
in that case i don't understand why it's contents are unexpectedly destroyed. they should be explicitly destroyed at application exit, before oduninitialize().
vladimir
re:
iam using dwgdirect version 1.11. yeah you are right. dwgcollection is a map: string, oddbdatabaseptr .and this is defined in the class declaration of exhostappservices
last edited by aparna; 16th july 2007 at 07:51 amfff">.
i looked at the 1.11 exhostappservices
dwgcollection there is designed to skip opening drawing second time, but it does not keep the drawings. drawings are stored by application.
you may redesign the cache, to store smart pointers (in the example it stores raw pointers), but you will be responsible for the actual release of them, at the end of the application.
vladimir
iam not clear with what you suggested. please let me know in detail.
dwgcollection will hold the file names i suppose. but how we can store
a smart pointer.
last edited by aparna; 16th july 2007 at 09:14 pmfff">.
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)