In the code below VLD detects a memory leak if TestClass and getStaticObject are defined in a DLL. The DLL is built without VLD.
```
// some.dll
class TestClass
{
public:
TestClass()
{
buffer = new char[10];
}
~TestClass()
{
delete[] buffer;
}
private:
char* buffer;
};
TestClass& getStaticObject(void)
{
static TestClass object;
return object;
}
// ...
// end of some.dll
int main()
{
getStaticObject();
return 0;
}
```
```
// some.dll
class TestClass
{
public:
TestClass()
{
buffer = new char[10];
}
~TestClass()
{
delete[] buffer;
}
private:
char* buffer;
};
TestClass& getStaticObject(void)
{
static TestClass object;
return object;
}
// ...
// end of some.dll
int main()
{
getStaticObject();
return 0;
}
```