<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://pybullet.org/Bullet/phpBB3/app.php/feed/topic/2277" />

	<title>Real-Time Physics Simulation Forum</title>
	
	<link href="https://pybullet.org/Bullet/phpBB3/index.php" />
	<updated>2008-08-24T06:53:33+00:00</updated>

	<author><name><![CDATA[Real-Time Physics Simulation Forum]]></name></author>
	<id>https://pybullet.org/Bullet/phpBB3/app.php/feed/topic/2277</id>

		<entry>
		<author><name><![CDATA[z8000]]></name></author>
		<updated>2008-08-24T06:53:33+00:00</updated>

		<published>2008-08-24T06:53:33+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=9973#p9973</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=9973#p9973"/>
		<title type="html"><![CDATA[Re: *beginners* - Boiled Down 'HelloWorld' demo with OpenGL]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=9973#p9973"><![CDATA[
<blockquote class="uncited"><div>comes with even more memory leaks, </div></blockquote>What a great feature!  <img class="smilies" src="https://pybullet.org/Bullet/phpBB3/images/smilies/icon_wink.gif" width="15" height="15" alt=";-)" title="Wink"><br><br>Cheers<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=2649">z8000</a> — Sun Aug 24, 2008 6:53 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[abaraba]]></name></author>
		<updated>2008-08-23T12:04:18+00:00</updated>

		<published>2008-08-23T12:04:18+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=9956#p9956</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=9956#p9956"/>
		<title type="html"><![CDATA[Re: *beginners* - Boiled Down 'HelloWorld' demo with OpenGL]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=9956#p9956"><![CDATA[
yes, thanks  <br><br>i was very wrong about those objects being temporary as the allocated memory has nothing to do with a scope... maybe in Java<br><br>so, i realized just how terrible that practice could be, <br>but for the sake of conversation i still think my wrong source and correct source would compile in a binary with same memory footprint, with no memory leak because all the new() operators happen only once in the whole runtime of that application, so there will be no extra memory allocations, but about the same ...even after 100 years <img class="smilies" src="https://pybullet.org/Bullet/phpBB3/images/smilies/icon_wink.gif" width="15" height="15" alt=";-)" title="Wink"><br><br><br>btw,<br>4th BoiledDownDemo -"Katamari Damacy remake", screenshots &amp; download: <br><a href="http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=17&amp;t=2499" class="postlink">http://www.bulletphysics.com/Bullet/php ... =17&amp;t=2499</a><br><br>comes with even more memory leaks, <br>which i should really fix now that i know better.. thank you all for input and feel free to find more bugs!<br><br><br>cheers<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=2526">abaraba</a> — Sat Aug 23, 2008 12:04 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[z8000]]></name></author>
		<updated>2008-08-22T18:28:25+00:00</updated>

		<published>2008-08-22T18:28:25+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=9951#p9951</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=9951#p9951"/>
		<title type="html"><![CDATA[Re: *beginners* - Boiled Down 'HelloWorld' demo with OpenGL]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=9951#p9951"><![CDATA[
When you do not retain a pointer to a dynamically allocated object, and pass that object off to some other object or function that does not claim ownership of the dynamically allocated object, you have a memory leak.  <br><br>Yes, this was a trivial example and yes, the OS will reclaim the memory on exit.  However, what if your application needs to run for several hours?  A day?  A month?  Forevermore?  You'll run out of memory eventually and start swapping -- the kiss of death.<br><br>This is a core software engineering principle: any resource you create, you should also dispose of, or at least ensure proper ownership semantics.<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=2649">z8000</a> — Fri Aug 22, 2008 6:28 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[abaraba]]></name></author>
		<updated>2008-08-22T03:46:30+00:00</updated>

		<published>2008-08-22T03:46:30+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=9930#p9930</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=9930#p9930"/>
		<title type="html"><![CDATA[Re: *beginners* - Boiled Down 'HelloWorld' demo with OpenGL]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=9930#p9930"><![CDATA[
thanks, i appreciate that,<br>you make it perfectly clear... and of course i agree..<br><br><br>but,<br>in this particular example, if i was to make it properly i would need to add  2 more pointers as z8000 said and allocate them all the same, so in practice you would not know which binary is which, they would have the same memory footprint, eh?<br><br><br>or... how about,<br>instead adding one more of each "shape" and "motionState"... why not get rid of them completely, like this:<br><div class="codebox"><p>Code: </p><pre><code>box1 = new btRigidBody( btScalar(0.0), (new btDefaultMotionState(trans)),      (new btBoxShape(btVector3(20,20,20))), btVector3(0,0,0));  dynamicsWorld-&gt;addRigidBody(box1);box2 = new btRigidBody( btScalar(1.0), (new btDefaultMotionState(trans)),      (new btBoxShape(btVector3(5,5,5))), btVector3(1,1,1));  dynamicsWorld-&gt;addRigidBody(box2);</code></pre></div><br>program still compiles and works as ever, <br>i wonder what would Valgrind say about that?<br><br>but seriously, <br>whats happening in above example, who calls whom constructor there?<br>and would they still exist in memory as before (memory leak) or these objects are truly temporary now, since the very next line the handle to that memory will be lost and practically free to use for anything else, right?<br><br><br>cheers<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=2526">abaraba</a> — Fri Aug 22, 2008 3:46 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[chunky]]></name></author>
		<updated>2008-08-22T01:48:12+00:00</updated>

		<published>2008-08-22T01:48:12+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=9929#p9929</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=9929#p9929"/>
		<title type="html"><![CDATA[Re: *beginners* - Boiled Down 'HelloWorld' demo with OpenGL]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=9929#p9929"><![CDATA[
<blockquote class="uncited"><div>can compiler surprise us and actually compile that source so it doesnt leak?</div></blockquote>No.<br><blockquote class="uncited"><div>i was running "top" and i started and killed application over 20 times, it would always allocate about the same time of memory, would not allocate any more during execution and would free it all on exit</div></blockquote>Ah. See, you need to understand that the operating system is responsible for a lot of things rather than your application. The application launches and allocates memory, grabs other resources [eg, opens file handles]. The operating system keeps track of every resource that the application grabs. When the application quits, the operating system releases all resources that that application grabbed. Technically there are a few more complicated rules, but that's the essence of it.<br><br>top's memory usage meter is also terrible, do not rely on it for anything, ever, other than a vague "this application is probably using more memory than this other application" heuristic. The reasons for this are about three steps further on from the concept of leaks <img class="smilies" src="https://pybullet.org/Bullet/phpBB3/images/smilies/icon_smile.gif" width="15" height="15" alt=":-)" title="Smile"><br><blockquote class="uncited"><div>1.) when executed, program will allocate more memory than needed, but memory allocation system of the OS would free that memory after program is exited, so no big deal</div></blockquote>The second half of that is correct, the OS will clear the resource when the program exits. A program "allocating more memory than is needed" is only half the story. The issue is that a program may allocate a resource, then not free it. That's all that a leak is, simply put.<br><br>In my example there, the resource is created [via c++ new], but is never freed [with an appropriate c++ delete], so it's technically a leak. In the case there, it only leaks once ever, and only leaks a tiny bit, so I tolerate it.<br><blockquote class="uncited"><div>2.) when executed, program will allocate more memory than needed, BUT on exit Operating System would not be able to free that memory, so running program repeatedly would sooner or later consume all system memory</div></blockquote>Not possible, that would be a bug in your operating system.<br><blockquote class="uncited"><div>3.) when executed, bad program will keep trying to allocate memory, therefore using all of it until system crashes (this is my picture of memory leak and thats why i thought i would catch any memory leak by simply monitoring memory usage and not need any other tools)</div></blockquote>Well, you've captured the essence of why leaks are bad. Grabbing resources then not releasing them is bad. But again, you only have half the story.<br><br>Leaks are more of an issue when, instead of being a one-off thing like in my example, they're constant things. For example, imagine if you were working on a game where powerups appear and disappear regularly. If your powerups were leaking memory [for example, they allocate space for a string that is that powerup's name] but then don't clear it, then every time a powerup is created and deleted, you leak the memory that took up the space of that string. After your game has been running long enough, and enough powerups have been spawned and despawned, the memory usage of the game gets too high.<br><br>It's memory that you don't have a pointer to anymore, it's just sitting there. The operating system or runtime cannot free it because your operatingsystem or runtime need explicit support for things like keeping track of resources - C++ doesn't currently have such a thing.<br><br>Things like java or scripting languages don't have this problem because they do what's called "garbage collection", where the runtime keeps track of what memory is in-use, and when memory is no longer accessible, it gets freed automatically.<br><br><a href="http://en.wikipedia.org/wiki/Memory_leak" class="postlink">Wikipedia is your perpetual friend</a><br><br>You should also install valgrind. I know, I sound like a broken record, but get it anyway.<br><br>Gary (-;<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=2063">chunky</a> — Fri Aug 22, 2008 1:48 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[abaraba]]></name></author>
		<updated>2008-08-22T01:49:20+00:00</updated>

		<published>2008-08-22T01:21:33+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=9928#p9928</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=9928#p9928"/>
		<title type="html"><![CDATA[Re: *beginners* - Boiled Down 'HelloWorld' demo with OpenGL]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=9928#p9928"><![CDATA[
thanks for explanation,<br><br>yes, im working on Linux, but never in my life i used any sort of profiler or any such tools, i write my programs in Midnight Commander text editor and i never even used a debugger.. ever, so my questions my seem stupid and i appreciate your time to make it more clear<br><blockquote class="uncited"><div>&gt;&gt;"how did you detect memory leak, did you use any tool?"<br>It's just a logical thing.</div></blockquote>ok, i too know in theory about new/delete allocators and stuff, but what im saying is - are you sure? can compiler surprise us and actually compile that source so it doesnt leak?<br><br><br>i was running "top" and i started and killed application over 20 times, it would always allocate about the same time of memory, would not allocate any more during execution and would free it all on exit<br><br><br>maybe i dont understand what memory leak is, <br>but i just dont see any memory leaking anywhere?<br><br>basically i believe memory leak can be one of these cases:<br><br>1.) when executed, program will allocate more memory than needed, but memory allocation system of the OS would free that memory after program is exited, so no big deal<br><br>2.) when executed, program will allocate more memory than needed, BUT on exit Operating System would not be able to free that memory, so running program repeatedly would sooner or later consume all system memory<br><br>3.) when executed, bad program will keep trying to allocate memory, therefore using all of it until system crashes  (this is my picture of memory leak and thats why i thought i would catch any memory leak by simply monitoring memory usage and not need any other tools)<br><br>so, it seems to me that my memory leak is in 1st category, just like your spaceships, in which case i too dont care, just as i dont care declaring variable INT when smaller CHAR would do.. does that make sense or am i still overlooking something important?<br><br><br><br>btw,<br>i think i read that author of this library said somewhere on this forum that collision shapes could/should be reused, which i thought is exactly what i was doing<br><br><br>cheers,<br><br>gameBoX Linux<br><a href="http://www.geocities.com/ze_aks/myos.html" class="postlink">http://www.geocities.com/ze_aks/myos.html</a><p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=2526">abaraba</a> — Fri Aug 22, 2008 1:21 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[chunky]]></name></author>
		<updated>2008-08-21T19:05:53+00:00</updated>

		<published>2008-08-21T19:05:53+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=9924#p9924</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=9924#p9924"/>
		<title type="html"><![CDATA[Re: *beginners* - Boiled Down 'HelloWorld' demo with OpenGL]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=9924#p9924"><![CDATA[
<blockquote class="uncited"><div>could you explain a bit more how does that causes memory leak?</div></blockquote>Because it's impossible to know when to delete the motionstate, because it's shared between objects. To find out when no more objects are using it, you'd need to be using reference-counting, which in C++ is a pain in the ass.<br><br>Therefore, you just sit on the single motionstate and just forget about it. You leak a total of maybe 50 bytes, once during execution<br><blockquote class="uncited"><div>how did you detect memory leak, did you use any tool?</div></blockquote>It's just a logical thing.<br><br>In my game, all my spaceships share the same collision object by using a static pointer in the class:<div class="codebox"><p>Code: </p><pre><code>class SpaceShip {public:  SpaceShip() {    if(NULL == mShipShape) {      mShipShape = new btSphereShape(btScalar(5.0));    }  }protected:  static btCollisionShape *mShipShape;};btCollisionShape *TWSpaceShip::mShipShape = NULL;</code></pre></div>This code "leaks" in that a resource is allocated that is never cleared, but really I don't care since it's just a single collisionshape that for practical reasons is persistent for the life of the entire applications.<br><br>Regarding tools to detect leaks, valgrind is your friend. <a href="http://valgrind.org/" class="postlink">valgrind, valgrind, valgrind</a>. Learn it. Use it. Port your code to Linux if it doesn't already run on linux, just so you can use it. It's like various other applications - it's the category inventor and the category killer all in one.<br><blockquote class="uncited"><div>can you point out some more extreme or more obvious case where this 'bad practice' would cause more noticeable problems?</div></blockquote>If you're deleting everything and starting again. For example, if you delete the whole world and everything in it when you end the level, and create more for the next level. *that* is going to leak.<br><br>Gary (-;<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=2063">chunky</a> — Thu Aug 21, 2008 7:05 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[abaraba]]></name></author>
		<updated>2008-08-21T00:39:15+00:00</updated>

		<published>2008-08-21T00:39:15+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=9892#p9892</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=9892#p9892"/>
		<title type="html"><![CDATA[Re: *beginners* - Boiled Down 'HelloWorld' demo with OpenGL]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=9892#p9892"><![CDATA[
thanks for that,<br>i hear what you saying, but still dont see a problem..<br>only use 'shape' and 'motionState' at the beginning as a *temporary_structures* to pass on some values to constructors when initialising btRigidBody... they don't seem to complain? and i dont see how or where later in the code/main loop that matters? ..i mean, it works, eh?<br><br>as for memory leak,<br>could you explain a bit more how does that causes memory leak?<br>how did you detect memory leak, did you use any tool?<br><br>can you point out some more extreme or more obvious case where this 'bad practice' would cause more noticeable problems?<br><br><br>cheers<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=2526">abaraba</a> — Thu Aug 21, 2008 12:39 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[z8000]]></name></author>
		<updated>2008-08-20T16:16:11+00:00</updated>

		<published>2008-08-20T16:16:11+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=9879#p9879</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=9879#p9879"/>
		<title type="html"><![CDATA[Re: *beginners* - Boiled Down 'HelloWorld' demo with OpenGL]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=9879#p9879"><![CDATA[
Note that this example leaks memory.  You are reusing the same symbols, 'shape' and 'motionState', to refer to two different dynamically allocated objects.  You need to use 2 shapes, and 2 motion states.  Then at cleanup time, delete all 4.  I think the rule with Bullet with respect to memory is "if you allocate it, you own it, and therefore you delete it".  It's a good rule.<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=2649">z8000</a> — Wed Aug 20, 2008 4:16 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[abaraba]]></name></author>
		<updated>2008-08-16T03:27:10+00:00</updated>

		<published>2008-08-16T03:27:10+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=9794#p9794</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=9794#p9794"/>
		<title type="html"><![CDATA[Re: *beginners* - Boiled Down 'HelloWorld' demo with OpenGL]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=9794#p9794"><![CDATA[
good question,<br>i was asking myself the same thing few days ago and luckily i remembered.. <br><br><br>model is from Google Sketchup 3d warehouse:<br><a href="http://sketchup.google.com/3dwarehouse/" class="postlink">http://sketchup.google.com/3dwarehouse/</a><br><br>then you need to convert/export to something usable, try this for help:<br><a href="http://forums.devshed.com/game-development-141/converting-sketchup-models-to-3dst-519710.html" class="postlink">http://forums.devshed.com/game-developm ... 19710.html</a><br><br><br>then, <br>the sweet part is actually 3d modeling program called "Deep Exploration 3D" which has best 'save as' options i've seen in any program so far, among many ways to modify geometry on export and many formats there is also option to save mesh as "opengl display list" ...thats it! so, short answer is: *DEEP EXPLORATION* (made by Right Hemisphere)<br> <br><br>btw, Google 3D Warehouse models seem to be complete rubbish once they leave Sketchup format, even before, there seem to be something strange how those meshes are composed... i get inverted triangles everywhere and lots of overlapping triangles that i dont know how to fix, compact or tidy up... thats why i had to turn on double-sided polygons on and lighting off, as normals are not correct everywhere (if anywhere) <br><br><br>BUT, my new toy for "express 3d modeling resource" is 3D Ripper DX:<br><a href="http://www.deep-shadows.com/hax/3DRipperDX.htm" class="postlink">http://www.deep-shadows.com/hax/3DRipperDX.htm</a><br><br>its fantastic, i now have new mesh for a demo -Prince of Persia: Sands of Time- level map, taken with 3dripper saved as .obj, imported with Deep Exploration and exported to OpenGL display list..<br><br><br><br>cheers  <br><br>..what id really like tho is to be able to pass over emulator/plugin overlay to grab some meshes from ps2 or psx games like katamari damacy and  metal gear which i would use for my next game - "Metal Gear Katamari" where you roll up stuff around shadow moses until is big enough to roll up metal gear rex...  so far i can only get flat pancakes meshes from emulators with either 3dripper or 'glinterceptor and OGLE' ..naaa nanana nana...  katamari damacy..<br><br>..apparently they can rip from gamecube emulator but not any psx or ps2 emulator yet<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=2526">abaraba</a> — Sat Aug 16, 2008 3:27 am</p><hr />
]]></content>
	</entry>
	</feed>
