Qt4-preview-feedback Archive, March 2007
Fwd: QT4.3 More on Garbage Collection
Message 1 in thread
Many thanks for the new specify ownership ability for the ScriptEngine, this
indeed is what I was looking for. However I still have a problem, attached
is some sample code which appears to illustrate that there is a memory leak
issue within the scripting engine (complete source found here
http://www.holomatix.com/test/qtcodesample-05032007/testmem.zip). I allocate
a number of elements on an array which immediately falls out of scope and
will be garbage collected in the near future. This allocation occurs on a
timer and is repeated infinitum. It is clear that the garbage collect occurs
and frequently, however the peak memory usage still increases over time.
function FrameCycle()
{
var matrixArray = new Array;
for(var i = 0 ; i < 100; i++)
{
// 100 matrices of 400 bytes each per cycle
matrixArray[i] = new Matrix;
}
}
timerIdFrameCycle = setInterval(FrameCycle, 10 ); // Timer every 10ms call
FrameCycle()
For example, when built on a Windows machine, the application begins at 8MB
and grows to 10.5MB before the first garbage collection. After 5 minutes the
peak memory has risen to over 12MB, and continues to grow.
The QScriptValue entries for Matrix are marked as the responsibility of the
ScriptEngine to free after garbage collect as follows:
template<> static inline QScriptValue
qscriptQMetaObjectConstructor<QSMYMatrix>(QScriptContext *ctx, QScriptEngine
*eng)
{
return eng->newQObject(new QSMYMatrix(),
QScriptEngine::ScriptOwnership);
}
This appears to work correctly and the destructor for QSMYMatrix is called
correctly. Therefore I am at a loss as to why the memory should grow in such
a manner. (Note: I tried removing all the script from within the
script function
FrameCycle() and this does not have any memory fluctuations so it is
definately the script entries that is the cause of the problem).
Regards,
Simon Bourne
Message 2 in thread
Simon Bourne wrote:
> Many thanks for the new specify ownership ability for the
> ScriptEngine, this indeed is what I was looking for. However I still
> have a problem, attached is some sample code which appears to
> illustrate that there is a memory leak issue within the scripting
> engine (complete source found here
> http://www.holomatix.com/test/qtcodesample-05032007/testmem.zip). I
> allocate a number of elements on an array which immediately falls out
> of scope and will be garbage collected in the near future. This
> allocation occurs on a timer and is repeated infinitum. It is clear
> that the garbage collect occurs and frequently, however the peak
> memory usage still increases over time.
Hi Simon,
Thanks for the example code. I've tried it on Linux, and there the
memory stops growing after a couple of minutes. I left it running for
more than half an hour, without any further change in memory
consumption. I'll get back to you once I've tried it on Windows as well.
Can you verify that memory does indeed continue to grow without bound on
your system?
Regards,
Kent
>
> function FrameCycle()
> {
> var matrixArray = new Array;
> for(var i = 0 ; i < 100; i++)
> {
> // 100 matrices of 400 bytes each per cycle
> matrixArray[i] = new Matrix;
> }
> }
> timerIdFrameCycle = setInterval(FrameCycle, 10 ); // Timer every 10ms
> call FrameCycle()
>
> For example, when built on a Windows machine, the application begins
> at 8MB and grows to 10.5MB before the first garbage collection. After
> 5 minutes the peak memory has risen to over 12MB, and continues to grow.
>
> The QScriptValue entries for Matrix are marked as the responsibility
> of the ScriptEngine to free after garbage collect as follows:
>
> template<> static inline QScriptValue
> qscriptQMetaObjectConstructor<QSMYMatrix>(QScriptContext *ctx,
> QScriptEngine *eng)
> {
> return eng->newQObject(new QSMYMatrix(),
> QScriptEngine::ScriptOwnership);
> }
>
> This appears to work correctly and the destructor for QSMYMatrix is
> called correctly. Therefore I am at a loss as to why the memory should
> grow in such a manner. (Note: I tried removing all the script from
> within the script function FrameCycle() and this does not have any
> memory fluctuations so it is definately the script entries that is the
> cause of the problem).
>
> Regards,
> Simon Bourne
>
To unsubscribe - send "unsubscribe" in the subject to qt4-preview-feedback-request@xxxxxxxxxxxxx
Message 3 in thread
Kent Hansen wrote:
> Simon Bourne wrote:
>
>> Many thanks for the new specify ownership ability for the
>> ScriptEngine, this indeed is what I was looking for. However I still
>> have a problem, attached is some sample code which appears to
>> illustrate that there is a memory leak issue within the scripting
>> engine (complete source found here
>> http://www.holomatix.com/test/qtcodesample-05032007/testmem.zip). I
>> allocate a number of elements on an array which immediately falls out
>> of scope and will be garbage collected in the near future. This
>> allocation occurs on a timer and is repeated infinitum. It is clear
>> that the garbage collect occurs and frequently, however the peak
>> memory usage still increases over time.
>>
> Hi Simon,
> Thanks for the example code. I've tried it on Linux, and there the
> memory stops growing after a couple of minutes. I left it running for
> more than half an hour, without any further change in memory
> consumption. I'll get back to you once I've tried it on Windows as well.
> Can you verify that memory does indeed continue to grow without bound on
> your system?
>
> Regards,
> Kent
>
On Windows, the memory grows to about 18MB, but then stops growing (I
left it running for a few hours), so there does not appear to be any
leak. We'll look into whether the peek memory usage can be made smaller,
though.
Regards,
Kent
>
>>
>> function FrameCycle()
>> {
>> var matrixArray = new Array;
>> for(var i = 0 ; i < 100; i++)
>> {
>> // 100 matrices of 400 bytes each per cycle
>> matrixArray[i] = new Matrix;
>> }
>> }
>> timerIdFrameCycle = setInterval(FrameCycle, 10 ); // Timer every 10ms
>> call FrameCycle()
>>
>> For example, when built on a Windows machine, the application begins
>> at 8MB and grows to 10.5MB before the first garbage collection. After
>> 5 minutes the peak memory has risen to over 12MB, and continues to grow.
>>
>> The QScriptValue entries for Matrix are marked as the responsibility
>> of the ScriptEngine to free after garbage collect as follows:
>>
>> template<> static inline QScriptValue
>> qscriptQMetaObjectConstructor<QSMYMatrix>(QScriptContext *ctx,
>> QScriptEngine *eng)
>> {
>> return eng->newQObject(new QSMYMatrix(),
>> QScriptEngine::ScriptOwnership);
>> }
>>
>> This appears to work correctly and the destructor for QSMYMatrix is
>> called correctly. Therefore I am at a loss as to why the memory should
>> grow in such a manner. (Note: I tried removing all the script from
>> within the script function FrameCycle() and this does not have any
>> memory fluctuations so it is definately the script entries that is the
>> cause of the problem).
>>
>> Regards,
>> Simon Bourne
>>
>>
>
>
>
To unsubscribe - send "unsubscribe" in the subject to qt4-preview-feedback-request@xxxxxxxxxxxxx
Message 4 in thread
Thanks Kent, I can confirm that for this test application it doesn't seem to
grow above about 18MB on my Windows system after considerable time. The
application does start at 9MB so there is a significant growth for the
script elements from the start.
Regards,
Simon
On 07/03/07, Kent Hansen <khansen@xxxxxxxxxxxxx> wrote:
>
> Kent Hansen wrote:
> > Simon Bourne wrote:
> >
> >> Many thanks for the new specify ownership ability for the
> >> ScriptEngine, this indeed is what I was looking for. However I still
> >> have a problem, attached is some sample code which appears to
> >> illustrate that there is a memory leak issue within the scripting
> >> engine (complete source found here
> >> http://www.holomatix.com/test/qtcodesample-05032007/testmem.zip). I
> >> allocate a number of elements on an array which immediately falls out
> >> of scope and will be garbage collected in the near future. This
> >> allocation occurs on a timer and is repeated infinitum. It is clear
> >> that the garbage collect occurs and frequently, however the peak
> >> memory usage still increases over time.
> >>
> > Hi Simon,
> > Thanks for the example code. I've tried it on Linux, and there the
> > memory stops growing after a couple of minutes. I left it running for
> > more than half an hour, without any further change in memory
> > consumption. I'll get back to you once I've tried it on Windows as well.
> > Can you verify that memory does indeed continue to grow without bound on
> > your system?
> >
> > Regards,
> > Kent
> >
> On Windows, the memory grows to about 18MB, but then stops growing (I
> left it running for a few hours), so there does not appear to be any
> leak. We'll look into whether the peek memory usage can be made smaller,
> though.
>
> Regards,
> Kent
>
> >
> >>
> >> function FrameCycle()
> >> {
> >> var matrixArray = new Array;
> >> for(var i = 0 ; i < 100; i++)
> >> {
> >> // 100 matrices of 400 bytes each per cycle
> >> matrixArray[i] = new Matrix;
> >> }
> >> }
> >> timerIdFrameCycle = setInterval(FrameCycle, 10 ); // Timer every 10ms
> >> call FrameCycle()
> >>
> >> For example, when built on a Windows machine, the application begins
> >> at 8MB and grows to 10.5MB before the first garbage collection. After
> >> 5 minutes the peak memory has risen to over 12MB, and continues to
> grow.
> >>
> >> The QScriptValue entries for Matrix are marked as the responsibility
> >> of the ScriptEngine to free after garbage collect as follows:
> >>
> >> template<> static inline QScriptValue
> >> qscriptQMetaObjectConstructor<QSMYMatrix>(QScriptContext *ctx,
> >> QScriptEngine *eng)
> >> {
> >> return eng->newQObject(new QSMYMatrix(),
> >> QScriptEngine::ScriptOwnership);
> >> }
> >>
> >> This appears to work correctly and the destructor for QSMYMatrix is
> >> called correctly. Therefore I am at a loss as to why the memory should
> >> grow in such a manner. (Note: I tried removing all the script from
> >> within the script function FrameCycle() and this does not have any
> >> memory fluctuations so it is definately the script entries that is the
> >> cause of the problem).
> >>
> >> Regards,
> >> Simon Bourne
> >>
> >>
> >
> >
> >
>
> To unsubscribe - send "unsubscribe" in the subject to
> qt4-preview-feedback-request@xxxxxxxxxxxxx
>
>