{"id":3953,"date":"2020-10-06T10:21:11","date_gmt":"2020-10-06T15:21:11","guid":{"rendered":"https:\/\/www.logikalsolutions.com\/wordpress\/?p=3953"},"modified":"2023-11-27T18:28:31","modified_gmt":"2023-11-28T00:28:31","slug":"memory-leaks","status":"publish","type":"post","link":"https:\/\/www.logikalsolutions.com\/wordpress\/uncategorized\/memory-leaks\/","title":{"rendered":"CopperSpice Experiments &#8211; Pt. 16"},"content":{"rendered":"\n<p>Now we must create a minimal GUI &#8220;Hello World&#8221; to use testing out the theory. It will also be needed as a bug report test case if this turns out to be a bug rather than &#8220;should have had this switch on when building CopperSpice.&#8221;<\/p>\n\n\n\n<p>In a terminal I did the following:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#0F111A\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"mkdir cs_gui_hello\nmkdir cs_gui_hello\/src\nmkdir cs_gui_hello\/resources\nmkdir cs_gui_hello_debug\nmkdir cs_gui_hello_build\ncp diamond\/resources\/*.gif cs_gui_hello\/resources\n\ncd cs_gui_hello\n\nroland@roland-amd-desktop:~\/Projects\/cs_gui_hello$ cp ..\/cs_hello\/*.txt .\nroland@roland-amd-desktop:~\/Projects\/cs_gui_hello$ cp ..\/cs_hello\/*.md .\nroland@roland-amd-desktop:~\/Projects\/cs_gui_hello$ \n\" style=\"color:#babed8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-ocean\" style=\"background-color: #0F111A\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #FFCB6B\">mkdir<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">cs_gui_hello<\/span><\/span>\n<span class=\"line\"><span style=\"color: #FFCB6B\">mkdir<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">cs_gui_hello\/src<\/span><\/span>\n<span class=\"line\"><span style=\"color: #FFCB6B\">mkdir<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">cs_gui_hello\/resources<\/span><\/span>\n<span class=\"line\"><span style=\"color: #FFCB6B\">mkdir<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">cs_gui_hello_debug<\/span><\/span>\n<span class=\"line\"><span style=\"color: #FFCB6B\">mkdir<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">cs_gui_hello_build<\/span><\/span>\n<span class=\"line\"><span style=\"color: #FFCB6B\">cp<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">diamond\/resources\/<\/span><span style=\"color: #BABED8\">*<\/span><span style=\"color: #C3E88D\">.gif<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">cs_gui_hello\/resources<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #82AAFF\">cd<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">cs_gui_hello<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #FFCB6B\">roland@roland-amd-desktop:~\/Projects\/cs_gui_hello$<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">cp<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">..\/cs_hello\/<\/span><span style=\"color: #BABED8\">*<\/span><span style=\"color: #C3E88D\">.txt<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">.<\/span><\/span>\n<span class=\"line\"><span style=\"color: #FFCB6B\">roland@roland-amd-desktop:~\/Projects\/cs_gui_hello$<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">cp<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">..\/cs_hello\/<\/span><span style=\"color: #BABED8\">*<\/span><span style=\"color: #C3E88D\">.md<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">.<\/span><\/span>\n<span class=\"line\"><span style=\"color: #FFCB6B\">roland@roland-amd-desktop:~\/Projects\/cs_gui_hello$<\/span><span style=\"color: #BABED8\"> <\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>In both CMakeLists.txt files I changed all cs_hello to cs_gui_hello and changed all Cs_Hello to Cs_GUI_Hello. I also updated the README.md. Then I renamed the build_info input file to: cs_hello_build_info.h.in and changed the important part of it to read:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#0F111A\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"#ifndef CS_GUI_HELLO_BUILD_INFO_H_IN\n#define CS_GUI_HELLO_BUILD_INFO_H_IN\n\n\/\/ Cs_GUI_Hello Version  &quot;x.y.z&quot;\nconstexpr const char *versionString = &quot;@PACKAGE_VERSION@&quot;;\n\n\/\/ Cs_GUI_Hello Build Date &quot;08\/17\/2017&quot;\nconstexpr const char *buildDate = &quot;@BUILD_DATE@&quot;;\n\n#endif\" style=\"color:#babed8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-ocean\" style=\"background-color: #0F111A\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #89DDFF; font-style: italic\">#ifndef<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #82AAFF\">CS_GUI_HELLO_BUILD_INFO_H_IN<\/span><\/span>\n<span class=\"line\"><span style=\"color: #89DDFF; font-style: italic\">#define<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #82AAFF\">CS_GUI_HELLO_BUILD_INFO_H_IN<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #464B5D; font-style: italic\">\/\/ Cs_GUI_Hello Version  &quot;x.y.z&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C792EA\">constexpr<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C792EA\">const<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C792EA\">char<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">*<\/span><span style=\"color: #BABED8\">versionString <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">&quot;<\/span><span style=\"color: #C3E88D\">@PACKAGE_VERSION@<\/span><span style=\"color: #89DDFF\">&quot;<\/span><span style=\"color: #89DDFF\">;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #464B5D; font-style: italic\">\/\/ Cs_GUI_Hello Build Date &quot;08\/17\/2017&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C792EA\">constexpr<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C792EA\">const<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C792EA\">char<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">*<\/span><span style=\"color: #BABED8\">buildDate <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">&quot;<\/span><span style=\"color: #C3E88D\">@BUILD_DATE@<\/span><span style=\"color: #89DDFF\">&quot;<\/span><span style=\"color: #89DDFF\">;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #89DDFF; font-style: italic\">#endif<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>The copy of the *.gif earlier was just to get the animated gif files to test with. Since I really needed only one file I manually created cs_gui_hello.qrc in a text editor.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#0F111A\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"<RCC&gt;\n    <qresource prefix=&quot;\/animations&quot;&gt;\n        <file&gt;resources\/spinning-red-diamond-4.gif<\/file&gt;\n    <\/qresource&gt;\n<\/RCC&gt;\n\" style=\"color:#babed8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-ocean\" style=\"background-color: #0F111A\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #89DDFF\">&lt;<\/span><span style=\"color: #BABED8\">RCC<\/span><span style=\"color: #89DDFF\">&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #BABED8\">    <\/span><span style=\"color: #89DDFF\">&lt;<\/span><span style=\"color: #BABED8\">qresource prefix<\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #89DDFF\">&quot;<\/span><span style=\"color: #C3E88D\">\/animations<\/span><span style=\"color: #89DDFF\">&quot;<\/span><span style=\"color: #89DDFF\">&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #BABED8\">        <\/span><span style=\"color: #89DDFF\">&lt;<\/span><span style=\"color: #BABED8\">file<\/span><span style=\"color: #89DDFF\">&gt;<\/span><span style=\"color: #BABED8\">resources<\/span><span style=\"color: #89DDFF\">\/<\/span><span style=\"color: #BABED8\">spinning<\/span><span style=\"color: #89DDFF\">-<\/span><span style=\"color: #BABED8\">red<\/span><span style=\"color: #89DDFF\">-<\/span><span style=\"color: #BABED8\">diamond<\/span><span style=\"color: #89DDFF\">-<\/span><span style=\"color: #F78C6C\">4.gif<\/span><span style=\"color: #89DDFF\">&lt;\/<\/span><span style=\"color: #BABED8\">file<\/span><span style=\"color: #89DDFF\">&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #BABED8\">    <\/span><span style=\"color: #89DDFF\">&lt;\/<\/span><span style=\"color: #BABED8\">qresource<\/span><span style=\"color: #89DDFF\">&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #89DDFF\">&lt;\/<\/span><span style=\"color: #BABED8\">RCC<\/span><span style=\"color: #89DDFF\">&gt;<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>That means there was one other change in the CMakeLists.txt file in the src directory. The following lines had to be uncommented and a new source file has to be added.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"458\" height=\"166\" src=\"https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/resources-88.png\" alt=\"\" class=\"wp-image-3955\" srcset=\"https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/resources-88.png 458w, https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/resources-88-300x109.png 300w\" sizes=\"(max-width: 458px) 100vw, 458px\" \/><figcaption class=\"wp-element-caption\">Have to compile qrc to source and add it to source list<\/figcaption><\/figure>\n\n\n\n<p>Now we open a terminal and test the assumption.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#0F111A\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"cd ~\/Projects\/cs_gui_hello_build\n\ncmake -G &quot;Ninja&quot; -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=..\/cs_gui_hello_debug -DCMAKE_PREFIX_PATH=\/usr\/lib\/cs_lib\/lib\/cmake\/CopperSpice ..\/cs_gui_hello\n\nninja\nninja install\n\nvalgrind --tool=memcheck --trace-children=yes --leak-check=full --show-leak-kinds=all --log-file=\/home\/roland\/hello.log .\/..\/cs_gui_hello_debug\/cs_gui_hello\n\" style=\"color:#babed8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-ocean\" style=\"background-color: #0F111A\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #82AAFF\">cd<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">~\/Projects\/cs_gui_hello_build<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #FFCB6B\">cmake<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">-G<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">&quot;<\/span><span style=\"color: #C3E88D\">Ninja<\/span><span style=\"color: #89DDFF\">&quot;<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">-DCMAKE_BUILD_TYPE=Debug<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">-DCMAKE_INSTALL_PREFIX=..\/cs_gui_hello_debug<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">-DCMAKE_PREFIX_PATH=\/usr\/lib\/cs_lib\/lib\/cmake\/CopperSpice<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">..\/cs_gui_hello<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #FFCB6B\">ninja<\/span><\/span>\n<span class=\"line\"><span style=\"color: #FFCB6B\">ninja<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">install<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #FFCB6B\">valgrind<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">--tool=memcheck<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">--trace-children=yes<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">--leak-check=full<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">--show-leak-kinds=all<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">--log-file=\/home\/roland\/hello.log<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">.\/..\/cs_gui_hello_debug\/cs_gui_hello<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"220\" height=\"155\" src=\"https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/what-we-see-copperspice.png\" alt=\"\" class=\"wp-image-3956\"\/><figcaption class=\"wp-element-caption\">What I see in CopperSpice<\/figcaption><\/figure>\n\n\n\n<p>No, I didn&#8217;t run it in valgrind the first few times. I did towards the end because I wanted to point out a bad thing in the code. It is code like I see in many many places on the Internet. You are in a hurry and bang something out fast then create this kind of self replicating screw-up as many many people find and re-use your stuff because it &#8220;seems to work.&#8221;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"808\" height=\"759\" src=\"https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/the-code.png\" alt=\"\" class=\"wp-image-3957\" srcset=\"https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/the-code.png 808w, https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/the-code-300x282.png 300w, https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/the-code-768x721.png 768w\" sizes=\"(max-width: 808px) 100vw, 808px\" \/><figcaption class=\"wp-element-caption\">The code<\/figcaption><\/figure>\n\n\n\n<p>Yes, I deliberately pasted an image so you couldn&#8217;t just scrape the code and go! I need to paste a few more images so you have a frame of reference. I went to the bottom of the log file and searched backwards for &#8220;lost.&#8221;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"82\" src=\"https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/hello-mem-leak-1024x82.png\" alt=\"\" class=\"wp-image-3958\" srcset=\"https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/hello-mem-leak-1024x82.png 1024w, https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/hello-mem-leak-300x24.png 300w, https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/hello-mem-leak-768x61.png 768w, https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/hello-mem-leak.png 1231w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">memory leak one<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"99\" src=\"https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/hello-mem-leak-2-1024x99.png\" alt=\"\" class=\"wp-image-3959\" srcset=\"https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/hello-mem-leak-2-1024x99.png 1024w, https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/hello-mem-leak-2-300x29.png 300w, https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/hello-mem-leak-2-768x75.png 768w, https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/hello-mem-leak-2.png 1370w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">memory leak two<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"96\" src=\"https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/hello-mem-leak-3-1024x96.png\" alt=\"\" class=\"wp-image-3960\" srcset=\"https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/hello-mem-leak-3-1024x96.png 1024w, https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/hello-mem-leak-3-300x28.png 300w, https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/hello-mem-leak-3-768x72.png 768w, https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/hello-mem-leak-3.png 1367w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">memory leak 3<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"132\" src=\"https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/hello-mem-leak-5-1024x132.png\" alt=\"\" class=\"wp-image-3961\" srcset=\"https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/hello-mem-leak-5-1024x132.png 1024w, https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/hello-mem-leak-5-300x39.png 300w, https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/hello-mem-leak-5-768x99.png 768w, https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/hello-mem-leak-5-1536x198.png 1536w, https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/hello-mem-leak-5.png 1607w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Repeating memory leak<\/figcaption><\/figure>\n\n\n\n<p>Hopefully you can zoom in on the images to see the 10+K leak in the first image and the 700+ byte leak in the second followed by a pair of 500+ byte leaks. What is interesting about the last 512 byte leak image is that it repeats for every disk block read for the gif.<\/p>\n\n\n\n<p>All of this happened because of line 19 (or so I thought). QMovie doesn&#8217;t provide a constructor with a non-optional parent pointer as the first parameter. If you want to create in one line much like I did at line 19 you have to provide an empty QByteArray then the parent.<\/p>\n\n\n\n<p>Now we get to why I pointed out the qDebug() statement in the last post.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"851\" height=\"95\" src=\"https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/no-supported-formats.png\" alt=\"\" class=\"wp-image-3962\" srcset=\"https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/no-supported-formats.png 851w, https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/no-supported-formats-300x33.png 300w, https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/no-supported-formats-768x86.png 768w\" sizes=\"(max-width: 851px) 100vw, 851px\" \/><figcaption class=\"wp-element-caption\">no supported formats<\/figcaption><\/figure>\n\n\n\n<p>There are no supported formats. I am hoping there is just a switch needed for compilation of CopperSpice that was missing when I built. It would be odd for the documentation to be way ahead of the implementation.<\/p>\n\n\n\n<p>I changed the code to see if parentage would fix the leak because you can&#8217;t really do much cleanup when the source ends with:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#0F111A\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"return a.exec();\" style=\"color:#babed8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-ocean\" style=\"background-color: #0F111A\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #89DDFF; font-style: italic\">return<\/span><span style=\"color: #BABED8\"> a<\/span><span style=\"color: #89DDFF\">.<\/span><span style=\"color: #82AAFF\">exec<\/span><span style=\"color: #89DDFF\">();<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>I have had to do cleanup over the years. You end up coding something like:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#0F111A\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"int retVal = a.exec();\n\/*\n *  Do all of of your cleanup paying special attention\n * to the fact you no longer have an event loop so much\n * of the Qt cleanup won't work because a surprising amount\n * queues an event.\n *\/\nreturn retVal;\n\" style=\"color:#babed8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-ocean\" style=\"background-color: #0F111A\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #C792EA\">int<\/span><span style=\"color: #BABED8\"> retVal <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #BABED8\"> a<\/span><span style=\"color: #89DDFF\">.<\/span><span style=\"color: #82AAFF\">exec<\/span><span style=\"color: #89DDFF\">();<\/span><\/span>\n<span class=\"line\"><span style=\"color: #464B5D; font-style: italic\">\/*<\/span><\/span>\n<span class=\"line\"><span style=\"color: #464B5D; font-style: italic\"> *  Do all of of your cleanup paying special attention<\/span><\/span>\n<span class=\"line\"><span style=\"color: #464B5D; font-style: italic\"> * to the fact you no longer have an event loop so much<\/span><\/span>\n<span class=\"line\"><span style=\"color: #464B5D; font-style: italic\"> * of the Qt cleanup won&#39;t work because a surprising amount<\/span><\/span>\n<span class=\"line\"><span style=\"color: #464B5D; font-style: italic\"> * queues an event.<\/span><\/span>\n<span class=\"line\"><span style=\"color: #464B5D; font-style: italic\"> *\/<\/span><\/span>\n<span class=\"line\"><span style=\"color: #89DDFF; font-style: italic\">return<\/span><span style=\"color: #BABED8\"> retVal<\/span><span style=\"color: #89DDFF\">;<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>I changed the code to read as follows:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#0F111A\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"#include <QApplication&gt;\n#include <QMainWindow&gt;\n#include <QLabel&gt;\n#include <QVBoxLayout&gt;\n#include <QMovie&gt;\n#include <QByteArray&gt;\n\n\nint main( int argc, char *argv[] )\n{\n    QApplication a( argc, argv );\n\n    QMainWindow mw;\n\n    QLabel *hello = new QLabel( &quot;Hello World!&quot; );\n\n    qDebug() << &quot;supported formats: &quot; << QMovie::supportedFormats();\n\n    QLabel *movieLabel = new QLabel();\n    QByteArray emptyFormat;\n    movieLabel-&gt;setMovie( new QMovie( &quot;:\/\/animations\/spinning-red-diamond-4.gif&quot;, empty_format, movieLabel ) );\n\n    QVBoxLayout *layout = new QVBoxLayout();\n\n    layout-&gt;addWidget( hello );\n    layout-&gt;addWidget( movieLabel );\n\n    QWidget *w = new QWidget();\n\n    w-&gt;setLayout( layout );\n    mw.setCentralWidget( w );\n\n    mw.show();\n\n    return a.exec();\n}\n\" style=\"color:#babed8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-ocean\" style=\"background-color: #0F111A\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #89DDFF; font-style: italic\">#include<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">&lt;<\/span><span style=\"color: #C3E88D\">QApplication<\/span><span style=\"color: #89DDFF\">&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #89DDFF; font-style: italic\">#include<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">&lt;<\/span><span style=\"color: #C3E88D\">QMainWindow<\/span><span style=\"color: #89DDFF\">&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #89DDFF; font-style: italic\">#include<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">&lt;<\/span><span style=\"color: #C3E88D\">QLabel<\/span><span style=\"color: #89DDFF\">&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #89DDFF; font-style: italic\">#include<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">&lt;<\/span><span style=\"color: #C3E88D\">QVBoxLayout<\/span><span style=\"color: #89DDFF\">&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #89DDFF; font-style: italic\">#include<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">&lt;<\/span><span style=\"color: #C3E88D\">QMovie<\/span><span style=\"color: #89DDFF\">&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #89DDFF; font-style: italic\">#include<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">&lt;<\/span><span style=\"color: #C3E88D\">QByteArray<\/span><span style=\"color: #89DDFF\">&gt;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #C792EA\">int<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #82AAFF\">main<\/span><span style=\"color: #89DDFF\">(<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C792EA\">int<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #BABED8; font-style: italic\">argc<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C792EA\">char<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C792EA\">*<\/span><span style=\"color: #BABED8; font-style: italic\">argv<\/span><span style=\"color: #89DDFF\">[]<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #89DDFF\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #BABED8\">    QApplication <\/span><span style=\"color: #82AAFF\">a<\/span><span style=\"color: #89DDFF\">(<\/span><span style=\"color: #BABED8\"> argc<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #BABED8\"> argv <\/span><span style=\"color: #89DDFF\">);<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #BABED8\">    QMainWindow mw<\/span><span style=\"color: #89DDFF\">;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #BABED8\">    QLabel <\/span><span style=\"color: #89DDFF\">*<\/span><span style=\"color: #BABED8\">hello <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">new<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #82AAFF\">QLabel<\/span><span style=\"color: #89DDFF\">(<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">&quot;<\/span><span style=\"color: #C3E88D\">Hello World!<\/span><span style=\"color: #89DDFF\">&quot;<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">);<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #BABED8\">    <\/span><span style=\"color: #82AAFF\">qDebug<\/span><span style=\"color: #89DDFF\">()<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">&lt;&lt;<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">&quot;<\/span><span style=\"color: #C3E88D\">supported formats: <\/span><span style=\"color: #89DDFF\">&quot;<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">&lt;&lt;<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #FFCB6B\">QMovie<\/span><span style=\"color: #89DDFF\">::<\/span><span style=\"color: #82AAFF\">supportedFormats<\/span><span style=\"color: #89DDFF\">();<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #BABED8\">    QLabel <\/span><span style=\"color: #89DDFF\">*<\/span><span style=\"color: #BABED8\">movieLabel <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">new<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #82AAFF\">QLabel<\/span><span style=\"color: #89DDFF\">();<\/span><\/span>\n<span class=\"line\"><span style=\"color: #BABED8\">    QByteArray emptyFormat<\/span><span style=\"color: #89DDFF\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #BABED8\">    movieLabel<\/span><span style=\"color: #89DDFF\">-&gt;<\/span><span style=\"color: #82AAFF\">setMovie<\/span><span style=\"color: #89DDFF\">(<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">new<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #82AAFF\">QMovie<\/span><span style=\"color: #89DDFF\">(<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">&quot;<\/span><span style=\"color: #C3E88D\">:\/\/animations\/spinning-red-diamond-4.gif<\/span><span style=\"color: #89DDFF\">&quot;<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #BABED8\"> empty_format<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #BABED8\"> movieLabel <\/span><span style=\"color: #89DDFF\">)<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">);<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #BABED8\">    QVBoxLayout <\/span><span style=\"color: #89DDFF\">*<\/span><span style=\"color: #BABED8\">layout <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">new<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #82AAFF\">QVBoxLayout<\/span><span style=\"color: #89DDFF\">();<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #BABED8\">    layout<\/span><span style=\"color: #89DDFF\">-&gt;<\/span><span style=\"color: #82AAFF\">addWidget<\/span><span style=\"color: #89DDFF\">(<\/span><span style=\"color: #BABED8\"> hello <\/span><span style=\"color: #89DDFF\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #BABED8\">    layout<\/span><span style=\"color: #89DDFF\">-&gt;<\/span><span style=\"color: #82AAFF\">addWidget<\/span><span style=\"color: #89DDFF\">(<\/span><span style=\"color: #BABED8\"> movieLabel <\/span><span style=\"color: #89DDFF\">);<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #BABED8\">    QWidget <\/span><span style=\"color: #89DDFF\">*<\/span><span style=\"color: #BABED8\">w <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">new<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #82AAFF\">QWidget<\/span><span style=\"color: #89DDFF\">();<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #BABED8\">    w<\/span><span style=\"color: #89DDFF\">-&gt;<\/span><span style=\"color: #82AAFF\">setLayout<\/span><span style=\"color: #89DDFF\">(<\/span><span style=\"color: #BABED8\"> layout <\/span><span style=\"color: #89DDFF\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #BABED8\">    mw<\/span><span style=\"color: #89DDFF\">.<\/span><span style=\"color: #82AAFF\">setCentralWidget<\/span><span style=\"color: #89DDFF\">(<\/span><span style=\"color: #BABED8\"> w <\/span><span style=\"color: #89DDFF\">);<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #BABED8\">    mw<\/span><span style=\"color: #89DDFF\">.<\/span><span style=\"color: #82AAFF\">show<\/span><span style=\"color: #89DDFF\">();<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #BABED8\">    <\/span><span style=\"color: #89DDFF; font-style: italic\">return<\/span><span style=\"color: #BABED8\"> a<\/span><span style=\"color: #89DDFF\">.<\/span><span style=\"color: #82AAFF\">exec<\/span><span style=\"color: #89DDFF\">();<\/span><\/span>\n<span class=\"line\"><span style=\"color: #89DDFF\">}<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>Not only did I have all of the same leakage, there was new leakage for the QByteArray. This is the problem with these quick little test programs. Just a few lines of code gives you a whole lot of leakage.<\/p>\n\n\n\n<p>Few developers take the time to actually run valgrind or any other memory checking tool. Using tools like this in an AGILE world is something that is &#8220;never in the sprint.&#8221;<\/p>\n\n\n\n<p>To be fair, I went over to the other machine and ran valgrind on that little demo. There were lots of little leaks that seemed to all be in some Qt internal thing. Nothing I could really &#8220;fix.&#8221;<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#0F111A\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"valgrind --tool=memcheck --trace-children=yes --leak-check=full --show-leak-kinds=all --log-file=\/home\/roland\/hello.log .\/gui-hello\" style=\"color:#babed8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-ocean\" style=\"background-color: #0F111A\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #FFCB6B\">valgrind<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">--tool=memcheck<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">--trace-children=yes<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">--leak-check=full<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">--show-leak-kinds=all<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">--log-file=\/home\/roland\/hello.log<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">.\/gui-hello<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>The ideal situation is for your application, no matter how small, to never have the word &#8220;lost&#8221; on any of the blocks in your valgrind report. You won&#8217;t be able to get rid of &#8220;still reachable&#8221; without severely impacting performance. This generally happens because the compiler tool chain has its own memory management library helping new\/malloc out. Instead of allocating RAM from the system it goes and gets a big chunk then doles it out per each request your application makes. <\/p>\n\n\n\n<p>Sometimes there is even a switch you can add to the build command line to set the size. If you&#8217;ve done some stats or simply wrote a hokey little &#8220;free memory&#8221; slot hooked to a timer so you &#8220;know&#8221; about how much free memory their is during your test runs, you can set the initial allocation to be <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>(TOTAL_MEMORY - Smallest_Free_Memory - Estimated_Binary_Load_Size) <\/code><\/pre>\n\n\n\n<p>This will gain you a bit of performance. On a desktop running on grid power with high quality RAM chips, you won&#8217;t gain a lot. On an embedded system using the lowest power RAM one could find to conserve battery life, you can breath new life into the application by finding and using such a setting. Dynamic allocation on battery powered embedded targets typically sucks. This is especially true when the system has no GPU for some reason.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"615\" height=\"635\" src=\"https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/mem-leak-tues-1.png\" alt=\"\" class=\"wp-image-3965\" srcset=\"https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/mem-leak-tues-1.png 615w, https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/mem-leak-tues-1-291x300.png 291w\" sizes=\"(max-width: 615px) 100vw, 615px\" \/><figcaption class=\"wp-element-caption\">mainwindow.h<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"820\" height=\"655\" src=\"https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/mem-leak-tues-2.png\" alt=\"\" class=\"wp-image-3966\" srcset=\"https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/mem-leak-tues-2.png 820w, https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/mem-leak-tues-2-300x240.png 300w, https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/mem-leak-tues-2-768x613.png 768w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><figcaption class=\"wp-element-caption\">mainwindow.cpp<\/figcaption><\/figure>\n\n\n\n<p>So I created a MainWindow class and added it to my little gui hello test application. Yes, you see those deletes commented out. I ran the application with those deletes in place fully expecting a crash. A layout is supposed to become the parent of all non-parented things directly added to it. I should have died with a double delete error message but I didn&#8217;t.<\/p>\n\n\n\n<p>I honestly thought deleting m_widget would delete m_layout. It <em>should<\/em> have in my mind. My first run at this deleted only m_widget and I still had the big leaks from the movie. Adding deletion of the layout got rid of the big leaks the movie was previously creating.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"713\" height=\"195\" src=\"https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/leakage-summary.png\" alt=\"\" class=\"wp-image-3968\" srcset=\"https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/leakage-summary.png 713w, https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/leakage-summary-300x82.png 300w\" sizes=\"(max-width: 713px) 100vw, 713px\" \/><figcaption class=\"wp-element-caption\">Leakage summary<\/figcaption><\/figure>\n\n\n\n<p>Leaking 4K doesn&#8217;t sound bad until you realize the program only ran for a few seconds. If this was a medical device where you had 512MEG or less, I would be worried if the leakage increased over time. Something left on long enough leaking 3-4K every few seconds will rather quickly run out of RAM.<\/p>\n\n\n\n<p>Most of this stuff seems to be things I can do very little about.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"781\" height=\"151\" src=\"https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/xcb-loss.png\" alt=\"\" class=\"wp-image-3969\" srcset=\"https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/xcb-loss.png 781w, https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/xcb-loss-300x58.png 300w, https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/xcb-loss-768x148.png 768w\" sizes=\"(max-width: 781px) 100vw, 781px\" \/><figcaption class=\"wp-element-caption\">XCB leakage<\/figcaption><\/figure>\n\n\n\n<p>I know the developers of CopperSpice are currently working on XCB things as they recently released some code for XCB. Probably haven&#8217;t gotten around to running valgrind on things.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"193\" src=\"https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/qaccessible-loss-1024x193.png\" alt=\"\" class=\"wp-image-3970\" srcset=\"https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/qaccessible-loss-1024x193.png 1024w, https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/qaccessible-loss-300x56.png 300w, https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/qaccessible-loss-768x144.png 768w, https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/qaccessible-loss.png 1276w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">QAccessible loss one<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1020\" height=\"245\" src=\"https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/accessible-loss-2.png\" alt=\"\" class=\"wp-image-3971\" srcset=\"https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/accessible-loss-2.png 1020w, https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/accessible-loss-2-300x72.png 300w, https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/accessible-loss-2-768x184.png 768w\" sizes=\"(max-width: 1020px) 100vw, 1020px\" \/><figcaption class=\"wp-element-caption\">QAccessible loss two<\/figcaption><\/figure>\n\n\n\n<p>Part of me distinctly remembers QAccessible leakage in Qt 4.x . The other part of me worries about the QString8 I see there because that is new with CopperSpice. The 697 indirect loss repeated quite a few times in the file. A large part of that may well be tied to this 504 byte indirect loss. <\/p>\n\n\n\n<p>It is these sub-1K leaks that really bite you. People ignore them because they aren&#8217;t large. What people fail to realize is that they tend to happen often. I&#8217;m not picking on just these leaks. I&#8217;m talking about sub-1K leaks in <em>every<\/em> project with <strong>every<\/strong> tool set. It&#8217;s the end of the project and you have already run out of time so they just get ignored. Now you fail your ten day run-time test because your sub-1K leak happens often enough to consume all RAM.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1000\" height=\"237\" src=\"https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/fontconfig-leak.png\" alt=\"\" class=\"wp-image-3972\" srcset=\"https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/fontconfig-leak.png 1000w, https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/fontconfig-leak-300x71.png 300w, https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/10\/fontconfig-leak-768x182.png 768w\" sizes=\"(max-width: 1000px) 100vw, 1000px\" \/><figcaption class=\"wp-element-caption\">fontconfig leak<\/figcaption><\/figure>\n\n\n\n<p>The fontconfig leak most likely has to be kicked upstream to the libexpat people. XML libraries and tools are notorious for leakage. Honestly I&#8217;m surprised this one is so small.<\/p>\n\n\n\n<p>Why am I harping on memory leaks? Because I&#8217;m currently working on an editor. I don&#8217;t know about you, but on Linux machines I&#8217;ve been known to leave an editor up for over a week. I mean I save everything before I go home, but many times I never shut down. I want the cursor to be right where I left it in every file when I come in the next day. Sometimes I get called away and the thing is up for weeks on its own. Even on my machines with 16Gig or 24Gig of RAM just how long do you think it can last if it has a leak, especially in a background thread?<\/p>\n\n\n\n<p><a href=\"https:\/\/www.logikalsolutions.com\/wordpress\/uncategorized\/animated-gif-in-label\/\">&lt;Previous-part<\/a>    <a href=\"https:\/\/www.logikalsolutions.com\/wordpress\/uncategorized\/splitting-animated-gif\/\">Next-part&gt;<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Now we must create a minimal GUI &#8220;Hello World&#8221; to use testing out the theory. It will also be needed as a bug report test case if this turns out to be a bug rather than &#8220;should have had this switch on when building CopperSpice.&#8221; In a terminal I did the following: In both CMakeLists.txt files I changed all cs_hello to cs_gui_hello and changed all Cs_Hello to Cs_GUI_Hello. I also updated the README.md. Then I &hellip; <a title=\"CopperSpice Experiments &#8211; Pt. 16\" class=\"bnm-read-more\" href=\"https:\/\/www.logikalsolutions.com\/wordpress\/uncategorized\/memory-leaks\/\"><span class=\"screen-reader-text\">CopperSpice Experiments &#8211; Pt. 16<\/span>Read more<\/a><\/p>\n","protected":false},"author":2,"featured_media":3905,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[1504,1835,1859,1867],"class_list":["post-3953","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-c","tag-copperspice","tag-diamond-text-editor","tag-memory-leaks","bnm-entry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>CopperSpice Experiments - Pt. 16 &#8211; Logikal Blog<\/title>\n<meta name=\"description\" content=\"What started off as tracking down why an animated gif didn&#039;t show became a journey to kill off memory leaks. Follow the journey.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.logikalsolutions.com\/wordpress\/uncategorized\/memory-leaks\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"CopperSpice Experiments - Pt. 16 &#8211; Logikal Blog\" \/>\n<meta property=\"og:description\" content=\"What started off as tracking down why an animated gif didn&#039;t show became a journey to kill off memory leaks. Follow the journey.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.logikalsolutions.com\/wordpress\/uncategorized\/memory-leaks\/\" \/>\n<meta property=\"og:site_name\" content=\"Logikal Blog\" \/>\n<meta property=\"article:published_time\" content=\"2020-10-06T15:21:11+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-11-28T00:28:31+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/09\/diamond-green-and-gold.png\" \/>\n\t<meta property=\"og:image:width\" content=\"820\" \/>\n\t<meta property=\"og:image:height\" content=\"655\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"seasoned_geek\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"seasoned_geek\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/uncategorized\\\/memory-leaks\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/uncategorized\\\/memory-leaks\\\/\"},\"author\":{\"name\":\"seasoned_geek\",\"@id\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/#\\\/schema\\\/person\\\/c077f770ade13de7faaf616c3eac6842\"},\"headline\":\"CopperSpice Experiments &#8211; Pt. 16\",\"datePublished\":\"2020-10-06T15:21:11+00:00\",\"dateModified\":\"2023-11-28T00:28:31+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/uncategorized\\\/memory-leaks\\\/\"},\"wordCount\":1403,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/#\\\/schema\\\/person\\\/c077f770ade13de7faaf616c3eac6842\"},\"image\":{\"@id\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/uncategorized\\\/memory-leaks\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/wp-content\\\/uploads\\\/2020\\\/09\\\/diamond-green-and-gold.png\",\"keywords\":[\"C++\",\"CopperSpice\",\"diamond text editor\",\"memory leaks\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/uncategorized\\\/memory-leaks\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/uncategorized\\\/memory-leaks\\\/\",\"url\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/uncategorized\\\/memory-leaks\\\/\",\"name\":\"CopperSpice Experiments - Pt. 16 &#8211; Logikal Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/uncategorized\\\/memory-leaks\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/uncategorized\\\/memory-leaks\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/wp-content\\\/uploads\\\/2020\\\/09\\\/diamond-green-and-gold.png\",\"datePublished\":\"2020-10-06T15:21:11+00:00\",\"dateModified\":\"2023-11-28T00:28:31+00:00\",\"description\":\"What started off as tracking down why an animated gif didn't show became a journey to kill off memory leaks. Follow the journey.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/uncategorized\\\/memory-leaks\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/uncategorized\\\/memory-leaks\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/uncategorized\\\/memory-leaks\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/wp-content\\\/uploads\\\/2020\\\/09\\\/diamond-green-and-gold.png\",\"contentUrl\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/wp-content\\\/uploads\\\/2020\\\/09\\\/diamond-green-and-gold.png\",\"width\":820,\"height\":655},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/uncategorized\\\/memory-leaks\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"CopperSpice Experiments &#8211; Pt. 16\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/#website\",\"url\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/\",\"name\":\"Logikal Blog\",\"description\":\"For people with attention spans longer than a Tweet\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/#\\\/schema\\\/person\\\/c077f770ade13de7faaf616c3eac6842\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/#\\\/schema\\\/person\\\/c077f770ade13de7faaf616c3eac6842\",\"name\":\"seasoned_geek\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ae9adac14079d84b909e635d7af986fe4568053af4fd9ff8d4109298c392493e?s=96&d=mm&r=r\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ae9adac14079d84b909e635d7af986fe4568053af4fd9ff8d4109298c392493e?s=96&d=mm&r=r\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ae9adac14079d84b909e635d7af986fe4568053af4fd9ff8d4109298c392493e?s=96&d=mm&r=r\",\"caption\":\"seasoned_geek\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ae9adac14079d84b909e635d7af986fe4568053af4fd9ff8d4109298c392493e?s=96&d=mm&r=r\"},\"description\":\"Roland Hughes started his IT career in the early 1980s. He quickly became a consultant and president of Logikal Solutions, a software consulting firm specializing in OpenVMS application and C++\\\/Qt touchscreen\\\/embedded Linux development. Early in his career he became involved in what is now called cross platform development. Given the dearth of useful books on the subject he ventured into the world of professional author in 1995 writing the first of the \\\"Zinc It!\\\" book series for John Gordon Burke Publisher, Inc. A decade later he released a massive (nearly 800 pages) tome \\\"The Minimum You Need to Know to Be an OpenVMS Application Developer\\\" which tried to encapsulate the essential skills gained over what was nearly a 20 year career at that point. From there \\\"The Minimum You Need to Know\\\" book series was born. Three years later he wrote his first novel \\\"Infinite Exposure\\\" which got much notice from people involved in the banking and financial security worlds. Some of the attacks predicted in that book have since come to pass. While it was not originally intended to be a trilogy, it became the first book of \\\"The Earth That Was\\\" trilogy: Infinite Exposure Lesedi - The Greatest Lie Ever Told John Smith - Last Known Survivor of the Microsoft Wars When he is not consulting Roland Hughes posts about technology and sometimes politics on his blog. He also has regularly scheduled Sunday posts appearing on the Interesting Authors blog.\",\"sameAs\":[\"https:\\\/\\\/theminimumyouneedtoknow.com\"],\"url\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/author\\\/seasoned_geek\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"CopperSpice Experiments - Pt. 16 &#8211; Logikal Blog","description":"What started off as tracking down why an animated gif didn't show became a journey to kill off memory leaks. Follow the journey.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.logikalsolutions.com\/wordpress\/uncategorized\/memory-leaks\/","og_locale":"en_US","og_type":"article","og_title":"CopperSpice Experiments - Pt. 16 &#8211; Logikal Blog","og_description":"What started off as tracking down why an animated gif didn't show became a journey to kill off memory leaks. Follow the journey.","og_url":"https:\/\/www.logikalsolutions.com\/wordpress\/uncategorized\/memory-leaks\/","og_site_name":"Logikal Blog","article_published_time":"2020-10-06T15:21:11+00:00","article_modified_time":"2023-11-28T00:28:31+00:00","og_image":[{"width":820,"height":655,"url":"https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/09\/diamond-green-and-gold.png","type":"image\/png"}],"author":"seasoned_geek","twitter_card":"summary_large_image","twitter_misc":{"Written by":"seasoned_geek","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.logikalsolutions.com\/wordpress\/uncategorized\/memory-leaks\/#article","isPartOf":{"@id":"https:\/\/www.logikalsolutions.com\/wordpress\/uncategorized\/memory-leaks\/"},"author":{"name":"seasoned_geek","@id":"https:\/\/www.logikalsolutions.com\/wordpress\/#\/schema\/person\/c077f770ade13de7faaf616c3eac6842"},"headline":"CopperSpice Experiments &#8211; Pt. 16","datePublished":"2020-10-06T15:21:11+00:00","dateModified":"2023-11-28T00:28:31+00:00","mainEntityOfPage":{"@id":"https:\/\/www.logikalsolutions.com\/wordpress\/uncategorized\/memory-leaks\/"},"wordCount":1403,"commentCount":0,"publisher":{"@id":"https:\/\/www.logikalsolutions.com\/wordpress\/#\/schema\/person\/c077f770ade13de7faaf616c3eac6842"},"image":{"@id":"https:\/\/www.logikalsolutions.com\/wordpress\/uncategorized\/memory-leaks\/#primaryimage"},"thumbnailUrl":"https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/09\/diamond-green-and-gold.png","keywords":["C++","CopperSpice","diamond text editor","memory leaks"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.logikalsolutions.com\/wordpress\/uncategorized\/memory-leaks\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.logikalsolutions.com\/wordpress\/uncategorized\/memory-leaks\/","url":"https:\/\/www.logikalsolutions.com\/wordpress\/uncategorized\/memory-leaks\/","name":"CopperSpice Experiments - Pt. 16 &#8211; Logikal Blog","isPartOf":{"@id":"https:\/\/www.logikalsolutions.com\/wordpress\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.logikalsolutions.com\/wordpress\/uncategorized\/memory-leaks\/#primaryimage"},"image":{"@id":"https:\/\/www.logikalsolutions.com\/wordpress\/uncategorized\/memory-leaks\/#primaryimage"},"thumbnailUrl":"https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/09\/diamond-green-and-gold.png","datePublished":"2020-10-06T15:21:11+00:00","dateModified":"2023-11-28T00:28:31+00:00","description":"What started off as tracking down why an animated gif didn't show became a journey to kill off memory leaks. Follow the journey.","breadcrumb":{"@id":"https:\/\/www.logikalsolutions.com\/wordpress\/uncategorized\/memory-leaks\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.logikalsolutions.com\/wordpress\/uncategorized\/memory-leaks\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.logikalsolutions.com\/wordpress\/uncategorized\/memory-leaks\/#primaryimage","url":"https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/09\/diamond-green-and-gold.png","contentUrl":"https:\/\/www.logikalsolutions.com\/wordpress\/wp-content\/uploads\/2020\/09\/diamond-green-and-gold.png","width":820,"height":655},{"@type":"BreadcrumbList","@id":"https:\/\/www.logikalsolutions.com\/wordpress\/uncategorized\/memory-leaks\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.logikalsolutions.com\/wordpress\/"},{"@type":"ListItem","position":2,"name":"CopperSpice Experiments &#8211; Pt. 16"}]},{"@type":"WebSite","@id":"https:\/\/www.logikalsolutions.com\/wordpress\/#website","url":"https:\/\/www.logikalsolutions.com\/wordpress\/","name":"Logikal Blog","description":"For people with attention spans longer than a Tweet","publisher":{"@id":"https:\/\/www.logikalsolutions.com\/wordpress\/#\/schema\/person\/c077f770ade13de7faaf616c3eac6842"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.logikalsolutions.com\/wordpress\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.logikalsolutions.com\/wordpress\/#\/schema\/person\/c077f770ade13de7faaf616c3eac6842","name":"seasoned_geek","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/ae9adac14079d84b909e635d7af986fe4568053af4fd9ff8d4109298c392493e?s=96&d=mm&r=r","url":"https:\/\/secure.gravatar.com\/avatar\/ae9adac14079d84b909e635d7af986fe4568053af4fd9ff8d4109298c392493e?s=96&d=mm&r=r","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ae9adac14079d84b909e635d7af986fe4568053af4fd9ff8d4109298c392493e?s=96&d=mm&r=r","caption":"seasoned_geek"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/ae9adac14079d84b909e635d7af986fe4568053af4fd9ff8d4109298c392493e?s=96&d=mm&r=r"},"description":"Roland Hughes started his IT career in the early 1980s. He quickly became a consultant and president of Logikal Solutions, a software consulting firm specializing in OpenVMS application and C++\/Qt touchscreen\/embedded Linux development. Early in his career he became involved in what is now called cross platform development. Given the dearth of useful books on the subject he ventured into the world of professional author in 1995 writing the first of the \"Zinc It!\" book series for John Gordon Burke Publisher, Inc. A decade later he released a massive (nearly 800 pages) tome \"The Minimum You Need to Know to Be an OpenVMS Application Developer\" which tried to encapsulate the essential skills gained over what was nearly a 20 year career at that point. From there \"The Minimum You Need to Know\" book series was born. Three years later he wrote his first novel \"Infinite Exposure\" which got much notice from people involved in the banking and financial security worlds. Some of the attacks predicted in that book have since come to pass. While it was not originally intended to be a trilogy, it became the first book of \"The Earth That Was\" trilogy: Infinite Exposure Lesedi - The Greatest Lie Ever Told John Smith - Last Known Survivor of the Microsoft Wars When he is not consulting Roland Hughes posts about technology and sometimes politics on his blog. He also has regularly scheduled Sunday posts appearing on the Interesting Authors blog.","sameAs":["https:\/\/theminimumyouneedtoknow.com"],"url":"https:\/\/www.logikalsolutions.com\/wordpress\/author\/seasoned_geek\/"}]}},"_links":{"self":[{"href":"https:\/\/www.logikalsolutions.com\/wordpress\/wp-json\/wp\/v2\/posts\/3953","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.logikalsolutions.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.logikalsolutions.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.logikalsolutions.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.logikalsolutions.com\/wordpress\/wp-json\/wp\/v2\/comments?post=3953"}],"version-history":[{"count":0,"href":"https:\/\/www.logikalsolutions.com\/wordpress\/wp-json\/wp\/v2\/posts\/3953\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.logikalsolutions.com\/wordpress\/wp-json\/wp\/v2\/media\/3905"}],"wp:attachment":[{"href":"https:\/\/www.logikalsolutions.com\/wordpress\/wp-json\/wp\/v2\/media?parent=3953"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.logikalsolutions.com\/wordpress\/wp-json\/wp\/v2\/categories?post=3953"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.logikalsolutions.com\/wordpress\/wp-json\/wp\/v2\/tags?post=3953"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}