libbb/MemoryInfo_lowMemory.cpp

Example use in C++
#include <bb/Application>
#include <bb/MemoryInfo>
#include <QObject>

class TestObject: public QObject {
Q_OBJECT
public:
    void releaseLowPriorityMemory();
    void releaseHighPriorityMemory();
public Q_SLOTS:
    void onAwake();
};

void TestObject::onLowMemory(bb::LowMemoryWarningLevel level) {
    if (level == bb::LowMemoryWarningLevel::LowPriority) {
        releaseLowPriorityMemory();
    } else if (level == bb::LowMemoryWarningLevel::HighPriority) {
        releaseHighPriorityMemory();
    }
}

int main(int argc, char **argv) {
    bb::Application app(argc, argv);
    bb::MemoryInfo memoryInfo;
    TestObject testObject;

    QObject::connect(&memoryInfo, SIGNAL( lowMemory(bb::LowMemoryWarningLevel::Type) ),
                     &testObject, SLOT( onLowMemory(bb::LowMemoryWarningLevel::Type) ));

    return app.exec();
}

Overview

Last modified: 2014-03-13

comments powered by Disqus