We manage some muliplatform code, and I've ran into this strangest memory-leak that happens only on linux.
I have a class which does not inherit nor being inherited. Since it does not have any dynamic allocartions that need to deallocated, I did not define a destructor for it (It does have some self destructing members - none of which is a pointer).
We noticed that the generation (new) and destruction (delete) of this class is causing a memory leak. defining and implementing an empty destructor on the header file did not solve the leak. moving the implementation to a source file - Did solve it. This (the leak) does not happen on windows, but does on linux.
I suppose it has something to do with compiler optimizations - but if so, I realy want to know the basis of this phoenomena, so I will know how to avoid such leak again.
Does anybody have an idea why this is happening ?
Here is a sketch of the code (not the real one of course...)
//file config.h
class Config
{       
    public:
        Config(std::shared_ptr<PR_Config> prConfig)
        {mPRConfig = engineConfig; mConfigOccurences++;};
        ~Config(){}
        shared_ptr<PR_Config>...
        ...
        ...
        ...
        //some public functions
    private:
        shared_ptr<PR_Config>...
        ...
        ...
        ...
        //some private members of shared_ptr type
};
//file: ConfigChecker.cpp
bool ConfigChecker::CheckConfig()
{
    shared_ptr<Config>  localConfig;
    localConfig = GenerateConfig();
    //Do some stuff with local config. did not change the reference count...
    if (locakConfig)
        return true;
    return false;
}
//file: Utils.cpp
shared_ptr<Config>  GenerateConfig()
{
    shared_ptr<Config>  pConfig = new Config(/*som parameters here...*/)
    return pConfig;
}
important notes:
- when moving the implemntation of ~Config to config.cpp file the leak stops.
 - we don't realy use shared_ptr but some other smart pointer with reference count and self-destruction. But I don't believe that it's doing the...