Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / [SOLUTION] how to prevent memory leak when deleting an object

Author
Message
mr Handy
17
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 9th Jun 2015 01:41
From the other discussion I want to highlight one tip:

If you are using shaders, right before object deletion line you should write two extra lines:

set vertex shader off 1
set pixel shader off 1
delete object 1

This unexpectedly will prevent memory leak when deleting an object.

P.S. Dear Princess CelestiaLee Bamber, please, fix at least this!

Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 9th Jun 2015 02:18
Unfortunately that simple fix seems to cause a crash if you need to use set display mode afterwards.

But thanks for the tip anyway.



Powered by Free Banners
mr Handy
17
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 9th Jun 2015 05:13
Despite the fact that I believe that the use of "set display mode" in the middle of the program is wrong (for several reasons),
I don't have problems with it.

This part runs okay:



Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 9th Jun 2015 14:35
Quote: "Despite the fact that I believe that the use of "set display mode" in the middle of the program is wrong (for several reasons),
I don't have problems with it."


Neither do I now - see my post on the other thread.



Powered by Free Banners
Kuper
17
Years of Service
User Offline
Joined: 25th Feb 2008
Playing: Planescape:Torment
Posted: 12th Jun 2015 00:19 Edited at: 12th Jun 2015 00:19
Nice snippet.
But maybe this will be better? From your second post:

So first detach shader and object, then delete them.
Anyway it is very important news for DBpro users.
Also I think Lee will not patch this leak code, I think he is using functions like yours to prevent them.If it is not - the most FPS Creator projects are with this vulnerables.

mr Handy
17
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 14th Jun 2015 02:31 Edited at: 14th Jun 2015 02:36
Quote: "But maybe this will be better?"

Deleting effect has no effect on leak. <- edit: hey, this is a tautology!

Fortunately only delete object command can cause the leak.

P.S. However I can't give a guarantee for the solution!

Login to post a reply

Server time is: 2025-08-09 02:30:05
Your offset time is: 2025-08-09 02:30:05