diff options
author | Kent Hansen <kent.hansen@nokia.com> | 2010-03-25 13:45:51 (GMT) |
---|---|---|
committer | Kent Hansen <kent.hansen@nokia.com> | 2010-03-25 14:05:13 (GMT) |
commit | 2fdfb3e0285ac535b63548d208da6dcae71105cc (patch) | |
tree | 4072a9c4cbc3ce49af779143f44776bdaf0c4f59 /src/script/api/qscriptengine_p.h | |
parent | 062af5a146e4875ace293823452347a572eda14f (diff) | |
download | Qt-2fdfb3e0285ac535b63548d208da6dcae71105cc.zip Qt-2fdfb3e0285ac535b63548d208da6dcae71105cc.tar.gz Qt-2fdfb3e0285ac535b63548d208da6dcae71105cc.tar.bz2 |
QtScript: Add API for reporting additional memory costs
QScriptEngine::reportAdditionalMemoryCost(int).
This function provides the ability to give a hint to the engine
that it should perhaps trigger garbage collection sooner rather
than later.
For example, if you've implemented a JS ByteArray class that
wraps a QByteArray, and a user constructs a few hundred
temporary ByteArray objects of large sizes, failure to report
the additional memory cost may cause the application's memory
consumption to grow and grow (because the script engine thinks
they are "cheap" objects, the GC won't kick in).
Reporting the correct size can be difficult (or impossible) in
some cases. For example, it's difficult to predict the total
amount of system memory & resources consumed by a QImage.
But even reporting a heuristic / approximate cost can be better
than reporting no cost.
Task-number: QTBUG-6238
Reviewed-by: Simon Hausmann
Diffstat (limited to 'src/script/api/qscriptengine_p.h')
-rw-r--r-- | src/script/api/qscriptengine_p.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/script/api/qscriptengine_p.h b/src/script/api/qscriptengine_p.h index 47e5d8a..70ab7c9 100644 --- a/src/script/api/qscriptengine_p.h +++ b/src/script/api/qscriptengine_p.h @@ -244,6 +244,7 @@ public: void mark(JSC::MarkStack& markStack); bool isCollecting() const; void collectGarbage(); + void reportAdditionalMemoryCost(int size); //flags that we set on the return value register for native function. (ie when codeBlock is 0) enum ContextFlags { |