Jump to content

Mem Usage Grows Continuously


Soamp
 Share

Recommended Posts

Hi,

We were testing our game's performance. We noticed that "Mem Usage" grows continuously until we get "Not enough memory" error.

We have evaluating our codes, we found two functions that cause this problem :

 

object.model:GetVelocity(0)

 

and

 

self.vehicle:GetTireMatrix(n)

 

Did anyone notice that before?

Btw. We use 2.32R5 and LUA.

 

Here is our confirmation tests description :

 

To confirm the cause, we performed a simple test. We use 40 oildrums. Normally the Mem Usage stays almost steady.

The problem begins when we add this to oildrum's code:

 

function object:Update()

object.model:GetVelocity(0)

end

 

It's a simple update script that only runs GetVelocity function.

In this simple test, Mem usage kept growing til "Not Enough Memory" showed up.

 

I also attached our test oilrum.lua

 

 

 

 

For evaluating the second function we can use the "ViperScout" vehicle. You drag a Viperscout in editor and the mem usage starts

to grow. If you create more viperscouts, you can feel the mem usage growing, more obvious.

 

Now we comment these lines in ViperScout.Lua :

 

Line no Line

---------------------------

18 self.tire[n]:SetMatrix( self.vehicle:GetTireMatrix(n) )

20 self.emitter[n]:SetMatrix(self.vehicle:GetTireMatrix(n))

23 speed = math.abs(self.model:GetVelocity(0).z)

 

we add "speed=0" after line 23 to prevent any errors.

 

Now there is no growing in mem usage! You can create viperscouts as many as you want and the mem usage stays almost steady!

 

I also attached our test ViperScout.lua

 

I think these are some bugs that occur in vehicle codes.

 

Sorry for such a long post ;-)

I hope solution is short ;-)

vehicle_viperscout.lua

oildrum.lua

Link to comment
Share on other sites

Maybe some did, but memory leaks are not always easy to catch,

so that may be the reason you have not got any answer. Usually

the community gives quick answers.

 

I cant help you either as I do all my stuff in C++ only.

Hopefully someone will help though.

 

At least you have now seen that someone read your post :)

AV MX Linux

Link to comment
Share on other sites

My applications leak 16kb a second if the window is out of focus, regardless of language.

52t__nvidia.png nVidia 530M cpu.gif Intel Core i7 - 2.3Ghz 114229_30245_16_hardware_memory_ram_icon.png 8GB DDR3 RAM Windows7_Start.gif Windows 7 Ultimate (64x)

-----

IconVisualStudio16.png Visual Studio 2010 Ultimate google-Chrome.png Google Chrome PhotoshopLinkIndicator.png Creative Suite 5 icon28.gif FL Studio 10 MicrosoftOfficeLive.png Office 15

-----

csharp.png Expert cpp.png Professional lua_icon.png Expert BMX Programmer

-----

i-windows-live-messenger-2009.pngskype-icon16.pngaim_online.pnggmail.pngicon_48x48_prism-facebook.pngtunein-web.pngyahoo.giftwitter16.png

Link to comment
Share on other sites

Interestingly, I'm not experiencing leaking at all, and I'm using C...

 

Loading a very primitive scene:

A large blue box as the floor with zero mass

3 small light-weight red boxes, and 1 small green box (weighing the same as all 3 red boxes.) Sample 'cars' seeing how much force is needed to make them move at a decent speed.

 

During loading, goes up to ~125 MB

Once loading is finished, it drops to ~48 MB and stays there

minimise the app, and the memory drops down to 8112 KB, and again, stays there (If the app is windowed it stays as ~48 MB)

bring the app back to being the active window, and memory usage will rise to ~12 MB, once again, stays there (Again, this only happens if the app is full-screen)

 

However, if my app does not sleep it's idle time, then when paused, the memory will climb to 13 MB, and then drop down to 2 MB. Climb to 13 again, drop back to 2 again, and so on...

 

So not only does it use less memory after minimising->restoring, but it also doesn't look any different (Presumably, textured meshes would lose their textures in this case - I'm still using coloured cubes as placeholders). I'm not saying that this is a fault, just an observation.

LE Version: 2.50 (Eventually)

Link to comment
Share on other sites

I think what soamp is seeing is only in the editor... I tried his viper and oildrum scripts, and it appears that the memory usage of the editor slowly rises...

 

I added this to the Update function of the oildrum script he provided:

collectgarbage(collect)

and it appears to have stopped the slow steady increase in memory usage.

 

I tried just his script and the original viperscout script together and it continuously raised the memory usage. I just added that one garbage collection to the oildrum script's Update function and it halted the increase. It appears as long as there is one garbage collection in one of the Update functions that it will do the job. I haven't noticed this problem in bmax with lua scripts maybe because I perform garbage collection in bmax? I cannot speak for the other languages, but perhaps that's why it hasn't been an issue if you are using another language in conjuction with lua.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...