The app I'm working on determines what DLL to load based on certain criteria. Each DLL implements the same abstract class such as in the example below:
Expand|Select|Wrap|Line Numbers
- class MyInterface
- {
- public:
- void initialize() = 0;
- void doSomething(int i) = 0;
- int getSomeVar() = 0;
- }
- class MyFirstImplementation: public MyInterface
- {
- public:
- void initialize();
- void doSomething(int i);
- int getSomeVar();
- private:
- int _someVar;
- int _anotherVar;
- }
However, I've noticed that the DLLs will "forget" the values in these variables after a while. The first call, immediately after the DLL has loaded the file, everything works. I try and access the variables again at another point in the program (I've made sure that nothing else has accessed the DLL by debugging the program line by line) and the functions begin to return junk values. I've even iterated through every function using for () and found that the second time the functions are called, they begin to return junk (but the first time everything works). No other program is accessing this DLL either.
Has anyone experienced the same or even similar situation? If so, are there any ways to fix it? Any help wold be appreciated. Thanks!