几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   DirectDWG (http://www.dimcax.com/hust/forumdisplay.php?f=89)
-   -   【转帖】select And Gdi Memory Leaks (http://www.dimcax.com/hust/showthread.php?t=18517)

yang686526 2009-05-07 03:31 PM

【转帖】select And Gdi Memory Leaks
 
select and gdi memory leaks
select and gdi memory leaks
i try to add a select fct in my view class (like cdwgviewer::select in odamfcapp)
it's work fine but i have a gdi memory leaks when i call select ... i forget to do something? can you help me?
thank you and happy new year
thierry
/////////////////////////////////////////////////////////////////////////////
void cmyview::onlbuttonup(uint nflags, cpoint point)
{
releasecapture();
odgsview* pview = getactiveview();
switch(m_interactionmode)
{
case kselectpoint:
{
crect l_rc;
l_rc.left = point.x ;
l_rc.right = point.x +6;
l_rc.top = point.y ;
l_rc.bottom= point.y +6;
select( &l_rc);
myssetdrawable* pmysset = ssetdrawable();
if(pmysset)
{
redrawwindow();
....
....
}
}
break;
}
cview::onlbuttonup(nflags, point);
}
///////////////////////////////////////////////////////////////////////////////////
void cmyview::select(const crect& p_rc)
{
oddblayoutptr playout = m_layoutid.safeopenobject();
oddbobjectid spaceid = playout->getblocktablerecordid();
if(m_pssetdrawable.isnull())
{
m_pssetdrawable = myssetdrawable::createobject();
}
myssetdrawable* pss = static_cast<myssetdrawable*>(m_pssetdrawable.get() );
odgsview* l_pview = getactiveview();
//// class selectionreactor ////////////////////////
class selectionreactor : public odgsselectionreactor
{
oddbobjectid m_layoutid;
oddbobjectid m_spaceid;
oddbobjectidarray* m_psset;
public:
selectionreactor(oddbobjectidarray& sset, const oddbobjectid& spaceid, const oddbobjectid& layoutid)
: m_psset(&sset)
, m_spaceid(spaceid)
, m_layoutid(layoutid)
{
m_psset->clear();
}
// notifications
bool selected(const odgidrawabledesc& drawabledesc)
{
const odgidrawabledesc* pdesc = &drawabledesc;
while(pdesc->pparent && pdesc->pparent->persistid != m_spaceid)
{
// mark drawable to be skipped
// (as we don't want to get more 'selected' notifications from its children)
pdesc->marktoskip(true);
pdesc = pdesc->pparent;
}
if(pdesc && pdesc->persistid)
{
pdesc->marktoskip(true); // regen abort for selected drawable
oddbobjectid id(pdesc->persistid);
oda_trace2("[%s]:<%s>\n",
id.gethandle().ascii().c_str(),
oddbobjectptr(id.safeopenobject())->isa()->name()
);
if(id!=m_layoutid)
{
m_psset->append(id);
}
}
return true;
}
}
l_selectionreactor(pss->m_sset, spaceid, m_layoutid);
/////////////////////////////////////////////////////
if(p_rc.top == p_rc.bottom && p_rc.left == p_rc.right)
{
// todo: implement point select
}
else
{
hcursor oldcur = ::getcursor();
::setcursor(::loadcursor(null, idc_wait));
l_pview->select((odgsdcpoint*)&p_rc, 2, &l_selectionreactor);
::setcursor(oldcur);
}
if(ssetdrawable())
{
//ondrag();
drawselection(false); // highlight
}
}
last edited by thierry; 5th january 2005 at 03:23 amfff">.
its a bugg ....?
i think it's a bugg ....
its only with wingdi device, the problem it's the same with odamfcapp
(some pen an brush not delete after select)
and after some select on a big dwg (500 ko) the gdi crash
have you a solution ?

is it possible to reproduce this problem in odamfcapp?
(i can't reproduce any crashes on files that is much bigger then 500kb)
sincerely yours,
george udov
buggs
is it possible to reproduce this problem in odamfcapp?
(i can't reproduce any crashes on files that is much bigger then 500kb)
yes, after many selection in this drawing, the gdi crash, and if you watch with a tool like gdileaks (from microsoft) you can see that not all the pen and brush are destroy....
thierry

thierry, it seems that you forget to attach a drawing
sincerely yours,
george udov
memory leaks
oh sorry,
i have the probleme with this file, but the memory leaks with some other ...
thierry
attached files (403.3 kb, 7 views)


thierry, could you please look, if you will still have problem with the version of exgigdigeometry.cpp, that you can find in folder george, server ftp.softdev.spb.ru (i'll send you login and password via private message).
sincerely yours,
george udov
exgigdigeometry.cpp
quote:
originally posted by george udov
thierry, could you please look, if you will still have problem with the version of exgigdigeometry.cpp, that you can find in folder george, server ftp.softdev.spb.ru (i'll send you login and password via private message).
i have a compile error ... 'odtruncatetolong' does not existe
---------------------------------------------
exgigdigeometry.cpp
d:\projet\communs\dwgdirect\dd_nonlibs\examples\ex render\win\exgigdigeometry.cpp(54) : error c2065: 'odtruncatetolong' : undeclared identifier
---------------------------------------------
regards
thierry

sorry - my error. please check out odround.h from same location to your dwgdirect's include folder.
sincerely yours,
george udov
thank you george, i have try your files. but the problem is the same. first i have recompiled the library, i have add some line to be sure to use the good file like that :
file* m_logfile;
m_logfile = fopen("c:\\testod.log","a");
fprintf(m_logfile, " wingdimodule createdeviceobject : \n");
fclose(m_logfile);
....
i run odamfcapp.exe with "gdiusage.exe ---gdi usage for windows xp/2000/nt 4.0" to watch the gdi memory with a little standard dwg
the gdi memory stat is:
first before select
bitmap 14
brush 5
dc 2
pen 0
second select
bitmap 14
brush 7
dc 2
pen 2
third select
bitmap 14
brush 9
dc 2
pen 6
and if i try with a more big dwg ... with a large select ...
first before select
bitmap 14
brush 5
dc 2
pen 0
second select
bitmap 14
brush 1252
dc 582
pen 2
third select
bitmap 14
brush 2505
dc 2
pen 1165
and after a few select gdi crash
my log file is
-------------------------------------------------------
wingdimodule initapp :
wingdimodule createdeviceobject :
exgigdigeometry :
exgswin32device :
exgsgdivectorizedevice :
wingdimodule createdeviceobject :
exgigdigeometry :
exgswin32device :
exgsgdivectorizedevice :
wingdimodule createviewobject :
wingdimodule createviewobject :
wingdimodule createviewobject :
wingdimodule initapp :
wingdimodule createdeviceobject :
exgigdigeometry :
exgswin32device :
exgsgdivectorizedevice :
wingdimodule createdeviceobject :
exgigdigeometry :
exgswin32device :
exgsgdivectorizedevice :
wingdimodule createviewobject :
wingdimodule createviewobject :
wingdimodule createviewobject :
-------------------------------------------------------
i hope this sample can help you
best regards
thierry
select function and gdi leak : i confirm
hi,
i have the same problem with select function :
crash after several selects
laurent
thanks,
laurent
good with opengl
thank you,
the pb is just with wingdi device, it's work fine with opengl and opengl-cache
thierry
wingdi leak
ok,
this bug will fix in the next release ?
laurent
thanks,
laurent
buggs
have you found a solution ? this buggs will correct in the next release?


所有的时间均为北京时间。 现在的时间是 06:40 AM.