Fixed #15 memory leak by introducing virtual function into all operation base classes to ensure the dependent class destructors are called
This commit is contained in:
parent
d4cc61817e
commit
5be21da7c2
9 changed files with 114 additions and 35 deletions
|
|
@ -61,7 +61,7 @@ class OpAlgoBase : public OpBase
|
|||
* Default destructor, which is in charge of destroying the algorithm
|
||||
* components but does not destroy the underlying tensors
|
||||
*/
|
||||
~OpAlgoBase();
|
||||
virtual ~OpAlgoBase() override;
|
||||
|
||||
/**
|
||||
* The init function is responsible for the initialisation of the algorithm
|
||||
|
|
@ -269,12 +269,19 @@ std::vector<char> OpAlgoBase<tX, tY, tZ>::fetchSpirvBinaryData()
|
|||
std::ifstream fileStream(this->mOptSpirvBinPath,
|
||||
std::ios::binary | std::ios::in | std::ios::ate);
|
||||
|
||||
if (!fileStream.good()) {
|
||||
throw std::runtime_error("Error reading file: " + this->mOptSpirvBinPath);
|
||||
}
|
||||
|
||||
size_t shaderFileSize = fileStream.tellg();
|
||||
fileStream.seekg(0, std::ios::beg);
|
||||
char* shaderDataRaw = new char[shaderFileSize];
|
||||
fileStream.read(shaderDataRaw, shaderFileSize);
|
||||
fileStream.close();
|
||||
|
||||
SPDLOG_WARN(
|
||||
"Kompute OpAlgoBase fetched {} bytes", shaderFileSize);
|
||||
|
||||
return std::vector<char>(shaderDataRaw,
|
||||
shaderDataRaw + shaderFileSize);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ class OpAlgoLhsRhsOut : public OpAlgoBase<tX, tY, tZ>
|
|||
* Default destructor, which is in charge of destroying the algorithm
|
||||
* components but does not destroy the underlying tensors
|
||||
*/
|
||||
~OpAlgoLhsRhsOut();
|
||||
virtual ~OpAlgoLhsRhsOut() override;
|
||||
|
||||
/**
|
||||
* The init function is responsible for ensuring that all of the tensors
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ class OpBase
|
|||
* intended to destroy the resources in the parent class. This can be done
|
||||
* by passing the mFreeTensors=false.
|
||||
*/
|
||||
~OpBase()
|
||||
virtual ~OpBase()
|
||||
{
|
||||
SPDLOG_DEBUG("Kompute OpBase destructor started");
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class OpCreateTensor : public OpBase
|
|||
* Default destructor which in this case expects the parent class to free
|
||||
* the tensors
|
||||
*/
|
||||
~OpCreateTensor();
|
||||
~OpCreateTensor() override;
|
||||
|
||||
/**
|
||||
* In charge of initialising the primary Tensor as well as the staging
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ class OpMult : public OpAlgoBase<tX, tY, tZ>
|
|||
* Default destructor, which is in charge of destroying the algorithm
|
||||
* components but does not destroy the underlying tensors
|
||||
*/
|
||||
~OpMult() {
|
||||
~OpMult() override {
|
||||
SPDLOG_DEBUG("Kompute OpMult destructor started");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue