drawText at paint callback of OpenGLAppComponent


#1

I’m trying to display some dynamic texts over my OpenGLComponent, but I figured out there are some steady increasing of memory. To reproduce this scenario, I set up a new test project and ran it.


As above image shows, It gives me exactly same result of my project, steadily increasing memory.
You can see 64byte continuous allocations are occur. But I don’t know much about Objective-C code, so I couldn’t investigate this issue more.

For sure, I create exactly same test project using ‘Component’ class. But it allocates and disallocates memory properly at ‘juce::OSXTypeface::getGlyphPosition’ and didn’t make any memory increasing.
It seems OpenGLAppComponent’s bug. Please let me know if I miss something.

Thank you :slight_smile:
And here is my test code.

class MainContentComponent   : public OpenGLAppComponent, public Timer
{
    public:
    MainContentComponent()
    {
        setSize (800, 600);
        startTimer(10);
        cnt = 0;
    }
    ~MainContentComponent()
    {
        shutdownOpenGL();
    }
    void initialise() override
    {
    }

    void shutdown() override
    {
    }
    void timerCallback() override
    {
        cnt++;
        repaint();
    }
    void render() override
    {
        OpenGLHelpers::clear (Colours::white);

    }
    void paint (Graphics& g) override
    {
        int x, y;
        x = cnt%getWidth();
        y = cnt%getHeight();
        g.drawText(String(cnt),x,y,100,50,Justification::centredBottom | Justification::horizontallyCentred);
    }
    void resized() override
    {
    }
private:
    int cnt;
    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainContentComponent)
};

#2

I might be wrong but I think this is issue.