memory leak in setplottype?
memory leak in setplottype?
hi,
i thought i had found a memory leak in oddbplotsettingsvalidator::setplottype, when running with dd2.0.3, and was advised to upgrade to 2.2. this i have done, but still get the same problem. the code i have isolated it to is as follows, in my cview class, when the user selects 'print'. i have trimmed this routine down so it now does nothing other than demonstrate the problem.
bool cmyview:

nprepareprinting(cprintinfo* pinfo)
{
oddbobjectid idlayout = oddbblocktablerecordptr(m_pdb->getactivelayoutbtrid().safeopenobject())->getlayoutid();
oddblayoutptr playout = idlayout.safeopenobject();
oddbplotsettings *pplotsettings = playout.get();
oddbplotsettingsvalidatorptr m_pvalidator = m_pdb->appservices()->plotsettingsvalidator();
playout->upgradeopen();
if (!m_pvalidator.isnull()) m_pvalidator->setplottype(pplotsettings, oddbplotsettings::kextents);
return 0;
}
if i comment out the second last line (the one calling setplottype) there is no memory leak. if i leave it in, i get 3 blocks leaked, of 12, 70 and 20 bytes.
so presumably there is either a leak in that routine, or it's allocating something i should be releasing, but don't know about.
any suggestions?
regards
ali smith
could you test your code with mfcapp, for example
code:
void cdwgview:

neditacisconversion()
{
oddbobjectid idlayout = oddbblocktablerecordptr(getdocument()->m_pdb->getactivelayoutbtrid().safeopenobject())->getlayoutid();
oddblayoutptr playout = idlayout.safeopenobject();
oddbplotsettings *pplotsettings = playout.get();
oddbplotsettingsvalidatorptr m_pvalidator = getdocument()->m_pdb->appservices()->plotsettingsvalidator();
playout->upgradeopen();
if (!m_pvalidator.isnull()) m_pvalidator->setplottype(pplotsettings, oddbplotsettings::kextents);
}
i test it with newly created file and call convertacis command (i change oneditacisconversion body for test purposes). it is possible that memory leaks are not in plot functionality, but in entity rendering. try to change kextents to kdisplay - it prevent extents calculation.
i cannot reproduce memory leaks with newly created file, and there is no 70 bytes allocation inside setplottype. please, attach your test file also.
i tried it in odamfcapp and it seems to work fine, no leak. in my own app, there is no problem if i use kdisplay, but i do get the leak if i use kextents. i have attached the dwg file i'm working with.
attached files (180.5 kb, 4 views)
i have checked your file with mfcapp and found nothing. are your application based on mfcapp or on vectorizeex sample?
also you can try set breakpoint to memory allocation with condition askedmemory == 70 and check stack position.
my app is based on mfcapp. where do i set the breakpoint for the memory allocation?
dd alloc module :
allocdll_export void* odrxalloc(size_t s)
{
return ::malloc( s );
}
or inside ::malloc( s );
last edited by sslezkin; 20th december 2006 at 08:07 amfff">.
unfortunately i don't have dd_alloc source.
i reproduced the leak in odamfcapp. we'll take care about it.
sergey slezkin
ok, i reproduce it in mfcapp static project only. something wrong with deallocation of loaded static modules.
last edited by sslezkin; 24th december 2006 at 11:54 pmfff">.
fixed, will be available with next release. fix is not very complex, so if somebody need it, please, ask for instructions (changes are inside of toolkit code)