memory management

This commit is contained in:
m-schuetz
2020-01-11 18:41:20 +01:00
parent c5913bd323
commit 40eaaffa6a
5 changed files with 8 additions and 4 deletions

View File

@@ -6,6 +6,7 @@
#include <filesystem>
#include <atomic>
#include <thread>
#include <memory>
#include "Points.h"
@@ -17,6 +18,7 @@
using json = nlohmann::json;
using std::shared_ptr;
using std::string;
using std::atomic_bool;
namespace fs = std::experimental::filesystem;
@@ -185,7 +187,7 @@ public:
uint64_t attributeBufferSize = numNew * attributes.byteSize;
auto cellBatch = make_shared<Points>();
cellBatch->attributeBuffer = new Buffer(attributeBufferSize);
cellBatch->attributeBuffer = make_shared<Buffer>(attributeBufferSize);
cellBatch->attributes = attributes;
if (cells[i] == nullptr) {

View File

@@ -151,7 +151,7 @@ public:
points = make_shared<Points>();
uint64_t attributeBufferSize = currentBatchSize * attributes.byteSize;
points->attributes = attributes;
points->attributeBuffer = new Buffer(attributeBufferSize);
points->attributeBuffer = make_shared<Buffer>(attributeBufferSize);
}
laszip_read_point(laszip_reader);

View File

@@ -4,9 +4,11 @@
#include <iostream>
#include <string>
#include <vector>
#include <memory>
using std::string;
using std::vector;
using std::shared_ptr;
struct Buffer {
void* data = nullptr;

View File

@@ -108,7 +108,7 @@ shared_ptr<Points> toBufferData(vector<Point>& subsample, shared_ptr<Chunk> chun
points->points = subsample;
points->attributes = attributes;
uint64_t attributeBufferSize = attributes.byteSize * numPoints;
points->attributeBuffer = new Buffer(attributeBufferSize);
points->attributeBuffer = make_shared<Buffer>(attributeBufferSize);
for (int i = 0; i < points->points.size(); i++) {

View File

@@ -121,7 +121,7 @@ shared_ptr<Points> loadChunk(shared_ptr<Chunk> chunk, Attributes attributes) {
shared_ptr<Points> points = make_shared<Points>();
points->attributes = attributes;
points->attributeBuffer = new Buffer(attributeBufferSize);
points->attributeBuffer = make_shared<Buffer>(attributeBufferSize);
int attributesByteSize = 4;