try fix memleak when test data have more features than training

This commit is contained in:
tqchen
2015-02-10 21:49:29 -08:00
parent 292f4f0e0d
commit a16cbedfab
2 changed files with 6 additions and 3 deletions

View File

@@ -503,12 +503,14 @@ class RegTree: public TreeModel<bst_float, RTreeNodeStat>{
/*! \brief fill the vector with sparse vector */
inline void Fill(const RowBatch::Inst &inst) {
for (bst_uint i = 0; i < inst.length; ++i) {
if (inst[i].index >= data.size()) continue;
data[inst[i].index].fvalue = inst[i].fvalue;
}
}
/*! \brief drop the trace after fill, must be called after fill */
inline void Drop(const RowBatch::Inst &inst) {
for (bst_uint i = 0; i < inst.length; ++i) {
if (inst[i].index >= data.size()) continue;
data[inst[i].index].flag = -1;
}
}