aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlmemoryprofiler_p.h
diff options
context:
space:
mode:
authorGlenn Watson <glenn.watson@nokia.com>2012-05-15 11:57:51 +1000
committerQt by Nokia <qt-info@nokia.com>2012-05-15 05:30:26 +0200
commite0eec47cac3f9f06613011dd70db74b7cd7d61ef (patch)
treea7def7294cf3d32493ba79f25b182889ea51bfd8 /src/qml/qml/qqmlmemoryprofiler_p.h
parentfec5068733373750d3a913fe3e6b3464a3f7275b (diff)
Add hooks for declarative memory profiler.
These macros effectively do nothing if the profiling library has not been preloaded. However, if the library is loaded they provide some additional context for each heap allocation, by tagging each subsequent allocation with the QML file that caused the allocation to occur. Change-Id: Ib1f56d0df0664e118e04e53e22a6942317b1baed Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'src/qml/qml/qqmlmemoryprofiler_p.h')
-rw-r--r--src/qml/qml/qqmlmemoryprofiler_p.h81
1 files changed, 81 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlmemoryprofiler_p.h b/src/qml/qml/qqmlmemoryprofiler_p.h
new file mode 100644
index 0000000000..61c881174a
--- /dev/null
+++ b/src/qml/qml/qqmlmemoryprofiler_p.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLMEMORYPROFILER_H
+#define QQMLMEMORYPROFILER_H
+
+#include <private/qtqmlglobal_p.h>
+
+QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+
+class QUrl;
+
+class Q_QML_PRIVATE_EXPORT QQmlMemoryScope
+{
+public:
+ explicit QQmlMemoryScope(const QUrl &url);
+ explicit QQmlMemoryScope(const char *string);
+ ~QQmlMemoryScope();
+
+private:
+ bool pushed;
+};
+
+class Q_QML_PRIVATE_EXPORT QQmlMemoryProfiler
+{
+public:
+ static void enable();
+ static void disable();
+ static bool isEnabled();
+
+ static void clear();
+ static void stats(int *allocCount, int *bytesAllocated);
+ static void save(const char *filename);
+};
+
+#define QML_MEMORY_SCOPE_URL(url) QQmlMemoryScope _qml_memory_scope(url)
+#define QML_MEMORY_SCOPE_STRING(s) QQmlMemoryScope _qml_memory_scope(s)
+
+QT_END_NAMESPACE
+QT_END_HEADER
+
+#endif // QQMLMEMORYPROFILER_H