[Interest] Qt3D memory leaks

Igor Mironchik igor.mironchik at gmail.com
Thu Apr 13 14:55:42 CEST 2017


Hi,

With example of error:

==1834== Thread 1:
==1834== Syscall param writev(vector[...]) points to uninitialised byte(s)
==1834==    at 0x7C5340D: ??? (syscall-template.S:84)
==1834==    by 0xD4AFF28: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
==1834==    by 0xD4B031C: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
==1834==    by 0xD4B0A76: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
==1834==    by 0xD4B0C43: xcb_flush (in 
/usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
==1834==    by 0xEBB696F: QXcbWindow::hide() (in 
/home/igor/Qt/5.8/gcc_64/lib/libQt5XcbQpa.so.5.8.0)
==1834==    by 0x652FF52: QWindow::setVisible(bool) (in 
/home/igor/Qt/5.8/gcc_64/lib/libQt5Gui.so.5.8.0)
==1834==    by 0x4FC5436: QWidgetPrivate::hide_sys() (in 
/home/igor/Qt/5.8/gcc_64/lib/libQt5Widgets.so.5.8.0)
==1834==    by 0x4FCC58C: QWidgetPrivate::hide_helper() (in 
/home/igor/Qt/5.8/gcc_64/lib/libQt5Widgets.so.5.8.0)
==1834==    by 0x4FD0C2F: QWidget::setVisible(bool) (in 
/home/igor/Qt/5.8/gcc_64/lib/libQt5Widgets.so.5.8.0)
==1834==    by 0x4FCC8D7: 
QWidgetPrivate::close_helper(QWidgetPrivate::CloseMode) (in 
/home/igor/Qt/5.8/gcc_64/lib/libQt5Widgets.so.5.8.0)
==1834==    by 0x4FEA2D5: ??? (in 
/home/igor/Qt/5.8/gcc_64/lib/libQt5Widgets.so.5.8.0)
==1834==  Address 0xe1afb89 is 4,537 bytes inside a block of size 21,152 
alloc'd
==1834==    at 0x4C2FB55: calloc (in 
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==1834==    by 0xD4AF8DB: xcb_connect_to_fd (in 
/usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
==1834==    by 0xD4B3610: xcb_connect_to_display_with_auth_info (in 
/usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
==1834==    by 0xCD8A809: _XConnectXCB (in 
/usr/lib/x86_64-linux-gnu/libX11.so.6.3.0)
==1834==    by 0xCD7B391: XOpenDisplay (in 
/usr/lib/x86_64-linux-gnu/libX11.so.6.3.0)
==1834==    by 0xEBA0C4A: 
QXcbConnection::QXcbConnection(QXcbNativeInterface*, bool, unsigned int, 
char const*) (in /home/igor/Qt/5.8/gcc_64/lib/libQt5XcbQpa.so.5.8.0)
==1834==    by 0xEBA6504: QXcbIntegration::QXcbIntegration(QStringList 
const&, int&, char**) (in 
/home/igor/Qt/5.8/gcc_64/lib/libQt5XcbQpa.so.5.8.0)
==1834==    by 0xE96143C: ??? (in 
/home/igor/Qt/5.8/gcc_64/plugins/platforms/libqxcb.so)
==1834==    by 0x6512BFA: QPlatformIntegrationFactory::create(QString 
const&, QStringList const&, int&, char**, QString const&) (in 
/home/igor/Qt/5.8/gcc_64/lib/libQt5Gui.so.5.8.0)
==1834==    by 0x6520435: 
QGuiApplicationPrivate::createPlatformIntegration() (in 
/home/igor/Qt/5.8/gcc_64/lib/libQt5Gui.so.5.8.0)
==1834==    by 0x6520EDC: 
QGuiApplicationPrivate::createEventDispatcher() (in 
/home/igor/Qt/5.8/gcc_64/lib/libQt5Gui.so.5.8.0)
==1834==    by 0x6E0F7D5: QCoreApplicationPrivate::init() (in 
/home/igor/Qt/5.8/gcc_64/lib/libQt5Core.so.5.8.0)
==1834==
==1834==
==1834== HEAP SUMMARY:
==1834==     in use at exit: 437,013 bytes in 6,177 blocks
==1834==   total heap usage: 1,584,865 allocs, 1,578,688 frees, 
816,770,283 bytes allocated
==1834==
==1834== LEAK SUMMARY:
==1834==    definitely lost: 1,192 bytes in 10 blocks
==1834==    indirectly lost: 13,690 bytes in 87 blocks
==1834==      possibly lost: 0 bytes in 0 blocks
==1834==    still reachable: 422,131 bytes in 6,080 blocks
==1834==         suppressed: 0 bytes in 0 blocks
==1834== Rerun with --leak-check=full to see details of leaked memory
==1834==
==1834== For counts of detected and suppressed errors, rerun with: -v
==1834== Use --track-origins=yes to see where uninitialised values come from
==1834== ERROR SUMMARY: 10226 errors from 11 contexts (suppressed: 0 from 0)


13.04.2017 15:39, william.crocker at analog.com пишет:
> On 04/13/2017 08:34 AM, Igor Mironchik wrote:
>> Hi,
>>
>> Strange, I launch 3Dtree on Linux under valgrind:
>>
>> ==4321== HEAP SUMMARY:
>> ==4321==     in use at exit: 439,965 bytes in 6,185 blocks
>> ==4321==   total heap usage: 2,207,719 allocs, 2,201,534 frees, 
>> 1,241,469,509
>> bytes allocated
>> ==4321==
>> ==4321== LEAK SUMMARY:
>> ==4321==    definitely lost: 1,080 bytes in 10 blocks
>> ==4321==    indirectly lost: 7,609 bytes in 55 blocks
>> ==4321==      possibly lost: 416 bytes in 1 blocks
>> ==4321==    still reachable: 430,860 bytes in 6,119 blocks
>> ==4321==         suppressed: 0 bytes in 0 blocks
>>
>
> Check the virtual image size on Linux,
> just to make sure it is not growing as well.
> That is the bottom line.
>
>> But on my Windows OS after each restart of tree I receive plus ~100MB 
>> additional
>> memory.
>>
>> As I can see this memory still reachable. But why 3Dtree allocates 
>> more and more
>> memory and doesn't use freed one?
>>
>> 13.04.2017 9:58, Sean Harmer пишет:
>>> Hi,
>>>
>>> On 13/04/2017 07:09, Igor Mironchik wrote:
>>>> Hello,
>>>>
>>>> 3Dtree has been updated. Now autumn is animated. Removed hand-made
>>>> classes of leaf geometry and mesh. Now example uses ready mesh 
>>>> prepared
>>>> in Blender. Modified a little constants of the tree. Example looks 
>>>> nice.
>>>> This is a benchmark of your video card, because leafs and branches are
>>>> stand alone objects (QEntity). For example 5 years tree has ~ 900
>>>> objects. My Intel Pentium with Intel HD graphics normally paint only 5
>>>> years tree, 6 years tree starts to slow down.
>>>
>>> Yes, at present each entity with a material/geometry renderer combo 
>>> gets
>>> translated to an OpenGL draw call. We are looking to add batching 
>>> (similar to
>>> how Qt Quick 2 works) but it's not there yet.
>>>
>>> If you don't need to address each individual leaf/branch in your 
>>> object model.
>>> E.g. if you're just rendering them, then you can get *much* better 
>>> performance
>>> by using instanced rendering.
>>>
>>> Essentially you have one entity representing all leaves. This entity 
>>> contains
>>> the material and geometry renderer as normal. The positions and any 
>>> other
>>> custom properties that vary between instances (rotation, leaf size, 
>>> leaf
>>> colour etc) should be placed into an additional attribute/buffer and 
>>> provided
>>> to the geometry renderer. On this attribute, set the divisor 
>>> property to 1
>>> meaning that 1 piece of data maps to 1 instance of the leave in the 
>>> scene.
>>> With this approach you will be able to render 10,000's leaves in a 
>>> single draw
>>> call. It maps through to a call to glDrawElementsInstanced() in case 
>>> you want
>>> to read up on it. Essentially you're moving the for loop over each 
>>> leaf on to
>>> the GPU.
>>>
>>> Typically, you'd have your data for the leaves in an array in C++ 
>>> and use this
>>> to populate the leaf instance buffer.
>>>
>>> The plan is to have a batcher that uses this instancing facility.
>>>
>>> Cheers,
>>>
>>> Sean
>>>
>>>>
>>>> And one more - now you can rotate the tree with the left mouse button.
>>>>
>>>>
>>>> 11.04.2017 12:15, Igor Mironchik пишет:
>>>>>
>>>>> Hi,
>>>>>
>>>>> I fixed a little 3Dtree. Now branches positions are correct. And I
>>>>> know that not all leafs is visible (this is because leaf geometry is
>>>>> implemented as plain which renders only on one side).
>>>>>
>>>>>
>>>>> 10.04.2017 13:20, Igor Mironchik пишет:
>>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> I guess that Qt3D has huge memory leaks.
>>>>>>
>>>>>> You can check it on this example: 
>>>>>> https://github.com/igormironchik/3Dtree
>>>>>>
>>>>>> It's 3D tree, that grows year by year.
>>>>>>
>>>>>> By default tree will grow 5 years (5 minutes).
>>>>>>
>>>>>> When tree grown you can restart tree. And here I delete all 
>>>>>> resources:
>>>>>>
>>>>>> void
>>>>>>
>>>>>> MainWindowPrivate::createTree()
>>>>>> {
>>>>>> if(m_tree)
>>>>>> {
>>>>>> for(constauto&e:m_rootEntity->childNodes())
>>>>>> e->deleteLater();
>>>>>> }
>>>>>> m_tree=newBranch(m_startPos,m_endPos,c_startBranchRadius,
>>>>>> true,m_rootEntity);
>>>>>> m_tree->setAge(0.0f);
>>>>>> m_tree->updatePosition();
>>>>>> m_tree->placeLeafs();
>>>>>> }
>>>>>>
>>>>>> But a lot of memory are eaten.
>>>>>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Interest mailing list
>>>> Interest at qt-project.org
>>>> http://lists.qt-project.org/mailman/listinfo/interest
>>>>
>>>
>>
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest




More information about the Interest mailing list