Xors3d Memory management

Started by Osoko, September 02, 2023, 12:13:03

Previous topic - Next topic

Osoko

Hello, 

I'm using Xors3D with B3D for my apps, and i have problems concerning memory cleaning.

2 problems occurs :

First with fastimageXors : 

=>Use Local image% = xCreateimageEx ( ..... ) then xFreeImageEx% (image%) in a loop and check the memory usage of the apps : it increase continuously.
=>Use Local image% = xLoadimageEx ( ..... ) then xFreeImageEx% (image%) in a loop and check the memory usage of the apps : it increase continuously.

===> The same for example with Xloadtexture and Xfreetexture : the ram stay stable.

Supppose the texture used by XCreateimageEx or  xLoadimageEx is not correctly cleaned.
The same happens if i change the FastXors xLoadimageEx Native function, using a local variable for Loadtexture :


*****************************************************************************************
Example : 

TMP_Texture= LoadTexture (fileName, textureFlags)
If TMP_Texture > 0
Local create_image_Handle% = xCreateImageEx ( TMP_Texture, ImageInfo_Width, ImageInfo_Height, imageFlags)
FreeTexture ( TMP_Texture ) : TMP_Texture = 0
Return create_image_Handle

***********************************************************************************************

I have found no way to get the ram cleaned. :'(

Looking at the Xors3D Side : 
I want to be able to switch from full screen to windowed mode.
So :

*************************************************************************
xCls()
 xClearWorld ( 1,1,1)
xReleaseGraphics()
xDestroyRenderWindow()
api_CloseWindow ( Aka_Handle )  ; Permit the procedure to work with windows 10 or 11

**************************************************************************
Then i reload the stuff in windowed mode use a new graphics3D command.

The result is the ram seems not to be cleaned and the amount of ram used by the apps increase each time i do the change.
At the end the apps failed at xGraphics3D command : no more ram left...

So I someone has an idea ????

Maybe the command
LPDIRECT3DDEVICE9 xGetDevice ()
 Returns a pointer to Direct3D device used by Xors3D.

Maybe it is possible to use this handle for correctly clean de memory ?
Or maybe i don't use the command a good way ?

For those who used Xorsd3D, have you the same problems ? ???

RemiD

first thing :
xors3d functions are not blitz3d functions, so i can't help.


a suggestion : have you tried to reproduce this issue with blitz3d only ? what happens in this case ?

Osoko

No, not yet, but there is no fastimage command in B3D, so the first problem can't occur.

For the second part, it seem's to concern only Xors3D with fastimage.

=> Loadtexture then FreeTexture work well in B3D and Xors3D : no memory leak. Cleaning OK

Suppose when you clean-up a level for the next one in B3D, you don't have memory leak ?

RemiD

#3
i remember having discussed this topic some years ago, and if i remember correctly, the answer was that you can't rely on what is written in the 'memory usage' of the 'task manager', because when something is tagged as 'freed' by blitz3d, Windows handles it its own way, not immediatly...


let me check with blitz3d only...

with this code :
Graphics(854,480,32,2)

Repeat

 timage = CreateImage(100,100)
 SetBuffer( ImageBuffer(timage) )
 Color( Rand(020,240), Rand(020,240), Rand(020,240) ) : Rect( 0, 0, Rand(10,100), Rand(10,100), True )
 
 SetBuffer( BackBuffer() )
 ClsColor( 000, 000, 000) : Cls()
 DrawImage( timage, 854/2-50, 480/2-50 )
 Flip()

 FreeImage(timage)

Until( KeyDown(1)=1 )

End()

blitz3d uses between 14mo and 16mo, after a few seconds or after 1 minute or after 10 minutes, and then when i open the task manager, it goes back to around 13.8mo...

so no problem on my side (with blitz3d only)

Osoko

It uses 14804k on my side.
But i didn't see any windows appears ?

Yes, the problem don't exist in bd3, Xors3D was at first a workaround to get B3D with 4K display.

For me it is a problem in FastImageXors command xLoadImageEx(...) : load an image and use it in 2D display provided by fastimage.

Images are simply not really cleaned from memory. As the process repeat itself at every image load, not cleaned, the ram used grows.

So the bug appears as the apps is more 1.5go ram, apps crash.

Could 32bit software use more than 1.5 Go ? 

For now, as a workaround, i will count every  xLoadImageEx() Texture amount added and remove it from my available ram. 

I will also simply no more delete image loaded since i could frequently happens an image is open then free, then reopen...

Maybe i'm not in the good section of the forum for this case, but as i've seen no post in userlib subsection, i post here.

RemiD

you may have better luck to get help, here :
https://forum.boolean.name/
section 'xors3d'

you can use google translate to write your post, read other posts...

Osoko

I didn't known this site, i'll check.

But does anyone still use FastimageXors and Xors3D ?

It is also available for Bmax.

I just wonder if other users have the same problems ? 

In case, if someone interested, i've done a little wrapper to use Xors3D with the same blitz Command, no more need for the x at the beginning.