OK. there is some example:

// we're using an OpenGL
class A
{
        protected int m_tex;
        this()
        {
// texture has been created in video memory. there is no GC resource.
                glGenTexture(1, &m_tex);
                glTexImage2D(....); // texture in video memory

        }


        ~this()
        {
                // release texture in video memory
                glDeleteTextures(1, &m_tex);
        }

}

void foo()
{
        // we do some operations...
        A[] arrA = new A[1_000_000];
        for (int i; i<arr.length; i++)
                arrA[i] = new A(); // generate texture


// do some operations... and return without explicit disposing of arrA
}


main(...)
{

        while(app.isNotExit)
        {
                foo();
        }

}


if GC does not guarantee the calling of dtor we can't be sure that some textures will be destroyed.
It will be followed by overflowing of the video memory.
And it is obvious, becouse we have no way to detect when the objects are destroyed.
The video memory will leaks.





Reply via email to