[LLVMdev] Possible memory leak in LLVM 2.5
Rob Grapes
Rob.Grapes at ur.co.nz
Mon May 17 18:27:39 PDT 2010
Hi,
I'm current using LLVM 2.5 to JIT code in a event driven language running on a game engine. Haven't updated to 2.7 yet, but I do intend to.
When checking for memory leaks I found that each time I was calling EE->runFunction after creating a stub function to execute an event, all the pass information was being repeatedly added to PMDataManager.
I have changed addAnalysisImplsPair to the following, which seems to have no side effects with what I am doing. Prior to that, AnalysisImpls contained thousands of entries and each time the vector gets realloced to accommodate more entries we lose a bigger chunk of memory.
void addAnalysisImplsPair(const PassInfo *PI, Pass *P) {
for (std::vector<std::pair<const PassInfo*, Pass*> >::iterator I =
AnalysisImpls.begin(); (I!=AnalysisImpls.end()); ++I)
{
if (I->first==PI && I->second==P)
{
// Return, if PassInfo and Pass are already in AnalysisImpls.
return;
}
}
std::pair<const PassInfo*, Pass*> pir = std::make_pair(PI,P);
AnalysisImpls.push_back(pir);
}
I'm probably doing something funny, or not as intended, but your comments would be appreciated.
Rob.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100518/c02cf9b3/attachment.html>
More information about the llvm-dev
mailing list