以下代码行存在内存泄漏问题:
auto state = newSpriteState();
这些是相关功能:
class SpriteState {
    protected:
        Vector3 position;
        int width, height;
        double rotation, scaling;
        int priority;
    public:
        SpriteState()
            : position(0,0,0),
            width(1), height(1),
            rotation(0), scaling(1.0f),
            priority(0)
        {}
    std::shared_ptr<SpriteState> newSpriteState()
    {
        return std::make_shared<SpriteState>();
    }
};
class Vector3 {
private:
    double x, y, z;
public:
    Vector3( double x_, double y_, double z_ )
    {
        x = x_; y = y_; z = z_;
    }
};
Intel Inspector 继续报告我在函数中存在内存泄漏newSpriteState();更具体地说std::make_shared<SpriteState>()。
更新
从评论来看,这似乎有一些外部原因,所以这里有更多代码:
bool Sprite::loadImage() {
    auto state = newSpriteState();
    initStateVector(0, state);
}
在哪里:
class Sprite
{
public:
    Sprite();
    std::map<const int, const std::shared_ptr<SpriteState>> stateVector;
    void initStateVector(const int line, std::shared_ptr<SpriteState>& state)
    { 
        stateVector.clear(); 
        stateVector.insert(std::make_pair( line, std::move(state) )); 
    }
    void loadImage();
}
Sprite为了清楚起见,我上传了我实际使用的课程的简化版本。
基本上,我正在分配 ashared_ptr<SpriteState>并坚持 a std::mapin class Sprite。