Re: [CrystalSpace] #995: Clean up some refcount problems in threadtest.cpp
"CrystalSpace" <[email protected]> Thu, 01 Aug 2013 19:26:37 -0000
| Newsgroups | gmane.comp.graphics.crystalspace.tracker |
|---|---|
| Message-ID | <[email protected]> |
#995: Clean up some refcount problems in threadtest.cpp
---------------------------+------------------------------------------------
Reporter: ralphcampbell | Owner: admin
Type: defect | Status: new
Priority: minor | Milestone:
Component: tools | Version: V2.1
Keywords: |
---------------------------+------------------------------------------------
Description changed by sunshine:
Old description:
> I ran valgrind on threadtest and found a couple of reference leaks.
> This change makes it easier to find memory leaks in other parts of CS.
>
> {{{
> Index: apps/tests/threadtest/threadtest.cpp
> ===================================================================
> --- apps/tests/threadtest/threadtest.cpp (revision 39538)
> +++ apps/tests/threadtest/threadtest.cpp (working copy)
> @@ -228,8 +228,8 @@
> {
> csInitializer::InitializeSCF(argc, argv);
> iObjectRegistry* objReg = csInitializer::CreateObjectRegistry();
> - csInitializer::CreateEventQueue(objReg);
> - csInitializer::CreateThreadManager(objReg);
> + csRef<iEventQueue> evq = csInitializer::CreateEventQueue(objReg);
> + csRef<iThreadManager> tm = csInitializer::CreateThreadManager(objReg);
>
> csRef<iThreadTest> threadTest;
> threadTest.AttachNew(new csThreadTest(objReg));
> @@ -271,7 +271,7 @@
> WaitForKey ();
> printf("\n");
>
> - objReg->Clear();
> + csInitializer::DestroyApplication(objReg);
>
> return 0;
> }
> }}}
New description:
I ran `valgrind` on `threadtest` and found a couple of reference leaks.
This change makes it easier to find memory leaks in other parts of CS.
{{{
#!diff
Index: apps/tests/threadtest/threadtest.cpp
===================================================================
--- apps/tests/threadtest/threadtest.cpp (revision 39538)
+++ apps/tests/threadtest/threadtest.cpp (working copy)
@@ -228,8 +228,8 @@
{
csInitializer::InitializeSCF(argc, argv);
iObjectRegistry* objReg = csInitializer::CreateObjectRegistry();
- csInitializer::CreateEventQueue(objReg);
- csInitializer::CreateThreadManager(objReg);
+ csRef<iEventQueue> evq = csInitializer::CreateEventQueue(objReg);
+ csRef<iThreadManager> tm = csInitializer::CreateThreadManager(objReg);
csRef<iThreadTest> threadTest;
threadTest.AttachNew(new csThreadTest(objReg));
@@ -271,7 +271,7 @@
WaitForKey ();
printf("\n");
- objReg->Clear();
+ csInitializer::DestroyApplication(objReg);
return 0;
}
}}}
--
--
Ticket URL: <http://www.crystalspace3d.org/trac/CS/ticket/995#comment:1>
CrystalSpace <http://www.crystalspace3d.org/>
Free open-source 3D SDK.
------------------------------------------------------------------------------
Get your SQL database under version control now!
Version control is standard for application code, but databases havent
caught up. So what steps can you take to put your SQL databases under
version control? Why should you start doing it? Read more to find out.
http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk