Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clear memory allocated for sampled data when constructing Dataset from text file #4890

Merged
merged 1 commit into from
Dec 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/io/dataset_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,9 @@ Dataset* DatasetLoader::LoadFromFile(const char* filename, int rank, int num_mac
auto sample_data = SampleTextDataFromMemory(text_data);
CheckSampleSize(sample_data.size(),
static_cast<size_t>(dataset->num_data_));
// construct feature bin mappers
// construct feature bin mappers & clear sample data
ConstructBinMappersFromTextData(rank, num_machines, sample_data, parser.get(), dataset.get());
std::vector<std::string>().swap(sample_data);
if (dataset->has_raw()) {
dataset->ResizeRaw(dataset->num_data_);
}
Expand All @@ -254,8 +255,9 @@ Dataset* DatasetLoader::LoadFromFile(const char* filename, int rank, int num_mac
}
CheckSampleSize(sample_data.size(),
static_cast<size_t>(dataset->num_data_));
// construct feature bin mappers
// construct feature bin mappers & clear sample data
ConstructBinMappersFromTextData(rank, num_machines, sample_data, parser.get(), dataset.get());
std::vector<std::string>().swap(sample_data);
if (dataset->has_raw()) {
dataset->ResizeRaw(dataset->num_data_);
}
Expand Down