Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.95.1a is out! (12/10/21); Blog post: Uniquifying the Factions, Part 2 (04/30/22)

Author Topic: Memory usage on background image load  (Read 2327 times)

Zaphide

  • Admiral
  • *****
  • Posts: 799
    • View Profile
Memory usage on background image load
« on: October 22, 2013, 01:19:22 PM »

Hi,

I've been adding custom background images to new systems and have noticed the following:
Code
29965216 [Thread-9] DEBUG com.fs.graphics.TextureLoader  - Loading image graphics/backgrounds/background1.jpg into existing tex id 318
 29965782 [Thread-9] DEBUG com.fs.graphics.TextureLoader  - Loaded 706.67 MB of texture data so far
 29965787 [Thread-9] INFO  com.fs.graphics.TextureLoader  - Cleaned buffer for texture graphics/backgrounds/background1.jpg (using cast)
30016785 [Thread-9] DEBUG com.fs.graphics.TextureLoader  - Loading image graphics/exerelin/backgrounds/purple_background1.jpg into existing tex id 318
 30017686 [Thread-9] DEBUG com.fs.graphics.TextureLoader  - Loaded 718.67 MB of texture data so far
 30017692 [Thread-9] INFO  com.fs.graphics.TextureLoader  - Cleaned buffer for texture graphics/exerelin/backgrounds/purple_background1.jpg (using cast)
 30048212 [Thread-9] DEBUG com.fs.graphics.TextureLoader  - Loading image graphics/exerelin/backgrounds/blue_background1.jpg into existing tex id 318
 30048756 [Thread-9] DEBUG com.fs.graphics.TextureLoader  - Loaded 730.67 MB of texture data so far
 30048762 [Thread-9] INFO  com.fs.graphics.TextureLoader  - Cleaned buffer for texture graphics/exerelin/backgrounds/blue_background1.jpg (using cast)
 30095163 [Thread-9] DEBUG com.fs.graphics.TextureLoader  - Loading image graphics/backgrounds/background4.jpg into existing tex id 318
 30095697 [Thread-9] DEBUG com.fs.graphics.TextureLoader  - Loaded 742.67 MB of texture data so far
 30095701 [Thread-9] INFO  com.fs.graphics.TextureLoader  - Cleaned buffer for texture graphics/backgrounds/background4.jpg (using cast)
30138179 [Thread-9] DEBUG com.fs.graphics.TextureLoader  - Loading image graphics/exerelin/backgrounds/blue_background1.jpg into existing tex id 318
 30138748 [Thread-9] DEBUG com.fs.graphics.TextureLoader  - Loaded 754.67 MB of texture data so far
 30138753 [Thread-9] INFO  com.fs.graphics.TextureLoader  - Cleaned buffer for texture graphics/exerelin/backgrounds/blue_background1.jpg (using cast)
 30172769 [Thread-9] DEBUG com.fs.graphics.TextureLoader  - Loading image graphics/backgrounds/background4.jpg into existing tex id 318
 30173298 [Thread-9] DEBUG com.fs.graphics.TextureLoader  - Loaded 766.67 MB of texture data so far
 30173303 [Thread-9] INFO  com.fs.graphics.TextureLoader  - Cleaned buffer for texture graphics/backgrounds/background4.jpg (using cast)
30211036 [Thread-9] DEBUG com.fs.graphics.TextureLoader  - Loading image graphics/exerelin/backgrounds/blue_background1.jpg into existing tex id 318
 30211570 [Thread-9] DEBUG com.fs.graphics.TextureLoader  - Loaded 778.67 MB of texture data so far
 30211576 [Thread-9] INFO  com.fs.graphics.TextureLoader  - Cleaned buffer for texture graphics/exerelin/backgrounds/blue_background1.jpg (using cast)
30247839 [Thread-9] DEBUG com.fs.graphics.TextureLoader  - Loading image graphics/exerelin/backgrounds/purple_background1.jpg into existing tex id 318
 30248678 [Thread-9] DEBUG com.fs.graphics.TextureLoader  - Loaded 790.67 MB of texture data so far
 30248682 [Thread-9] INFO  com.fs.graphics.TextureLoader  - Cleaned buffer for texture graphics/exerelin/backgrounds/purple_background1.jpg (using cast)
 30276655 [Thread-9] DEBUG com.fs.graphics.TextureLoader  - Loading image graphics/backgrounds/background1.jpg into existing tex id 318
 30277298 [Thread-9] DEBUG com.fs.graphics.TextureLoader  - Loaded 802.67 MB of texture data so far
 30277302 [Thread-9] INFO  com.fs.graphics.TextureLoader  - Cleaned buffer for texture graphics/backgrounds/background1.jpg (using cast)

As you can see it appears to be allocating additional chunks of 12MB for background images switching, and doesn't seem to free the previous lot.

None of the images I am using are remotely close to 12MB, and there are a couple of vanilla backgrounds loaded in that lot too which also cop the 12MB allocation.

Looking at the memory usage for StarSector, it was increasing every time the above background image changes occurred.
Logged

ValkyriaL

  • Admiral
  • *****
  • Posts: 2145
  • The Guru of Capital Ships.
    • View Profile
Re: Memory usage on background image load
« Reply #1 on: October 22, 2013, 01:27:04 PM »

Seems like you just found the biggest memory leak of all time. and the culprit of the out of memory bug in exerelin =D :P
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 20364
    • View Profile
Re: Memory usage on background image load
« Reply #2 on: October 22, 2013, 01:30:57 PM »

Ah... not actually a bug. The bit that prints the amount of stuff loaded doesn't account for some special logic for backgrounds that ensures they re-use existing memory.

Looking at the memory usage for StarSector, it was increasing every time the above background image changes occurred.

How are you looking at the memory usage? If you're checking it using task manager or some such, that's not going to be accurate at all, and actually isn't representative of how much memory the game is using vs how much the JVM has asked the system for.
Logged

Zaphide

  • Admiral
  • *****
  • Posts: 799
    • View Profile
Re: Memory usage on background image load
« Reply #3 on: October 22, 2013, 01:54:01 PM »

Ah... not actually a bug. The bit that prints the amount of stuff loaded doesn't account for some special logic for backgrounds that ensures they re-use existing memory.

OK was wondering that :)

Looking at the memory usage for StarSector, it was increasing every time the above background image changes occurred.

How are you looking at the memory usage? If you're checking it using task manager or some such, that's not going to be accurate at all, and actually isn't representative of how much memory the game is using vs how much the JVM has asked the system for.

Yep Task Manager Mac equivalent (top).

Anyway, thanks for the explanation :)
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 20364
    • View Profile
Re: Memory usage on background image load
« Reply #4 on: October 22, 2013, 01:58:09 PM »

Would be nice if that was it, though :)

Btw, the memory usage it prints out is useful for figuring out just how much graphics memory is necessary, if you look at the last number it prints once the game finishes loading.
Logged

theSONY

  • Admiral
  • *****
  • Posts: 673
  • Not a single Flux given
    • View Profile
Re: Memory usage on background image load
« Reply #5 on: October 22, 2013, 02:22:38 PM »

Too bad thats not IT
but there is problem with loading your game
you can get load error just by loading the very  same save file
just like your trying to capture your favorite ship, every next Load will make your game harder to play ( it will s-s-s-stutter) & finally unable to load
thats what i saw from my experience with the game
Logged
-the ABOMINATION - in progress

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 20364
    • View Profile
Re: Memory usage on background image load
« Reply #6 on: October 22, 2013, 02:31:53 PM »

Too bad thats not IT
but there is problem with loading your game
you can get load error just by loading the very  same save file
just like your trying to capture your favorite ship, every next Load will make your game harder to play ( it will s-s-s-stutter) & finally unable to load
thats what i saw from my experience with the game

This is with mods, right?

(Also, I did fix a bug in 0.6.2a that could contribute to this, though it shouldn't show up in vanilla regardless.)

(Also #2: this could be a symptom of a memory leak in a mod. A way to tell is to reload many times in a row to see if it gets progressively worse.)
Logged