Too much memory in use...

Post Reply
ChristienChapman
Member
Posts: 117
Joined: Sat May 28, 2022 00:04

Too much memory in use...

by ChristienChapman » Post

So Minetest Zombies Minigame has a soundtrack that is loaded into memory at all times. However, this is very unnecessary. Is there a program I can use to load songs into memory temporarily and when it is over clear it? I need to reduce memory use as the music is making Minetest take up 1.4GB in memory despite there being only 18.8MB of music. Please help

Code: Select all

-- All glory to God, Jesus Christ, and the Holy Spirit.


function playSong(song)

if song == "zombies" then
minetest.sound_play("zombies", { pos = {x=0, y=0, z=0}, max_hear_distance = 31000, gain = 1.0, })
end

if song == "prison" then
minetest.sound_play("prison", { pos = {x=0, y=0, z=0}, max_hear_distance = 31000, gain = 1.0, })
end

if song == "cell_outbreak" then
minetest.sound_play("cell_outbreak", { pos = {x=0, y=0, z=0}, max_hear_distance = 31000, gain = 1.0, })
end

if song == "surviving_for_a_while" then
minetest.sound_play("surviving_for_a_while", { pos = {x=0, y=0, z=0}, max_hear_distance = 31000, gain = 1.0, })
end

if song == "campsite" then
minetest.sound_play("campsite", { pos = {x=0, y=0, z=0}, max_hear_distance = 31000, gain = 1.0, })
end


if song == "five" then
minetest.sound_play("five", { pos = {x=0, y=0, z=0}, max_hear_distance = 31000, gain = 1.0, })
end


if song == "hotel" then
minetest.sound_play("hotel", { pos = {x=0, y=0, z=0}, max_hear_distance = 31000, gain = 1.0, })
end


if song == "jungle" then
minetest.sound_play("jungle", { pos = {x=0, y=0, z=0}, max_hear_distance = 31000, gain = 1.0, })
end


if song == "shelter" then
minetest.sound_play("shelter", { pos = {x=0, y=0, z=0}, max_hear_distance = 31000, gain = 1.0, })
end


if song == "survival" then
minetest.sound_play("survival", { pos = {x=0, y=0, z=0}, max_hear_distance = 31000, gain = 1.0, })
end


if song == "the_pentagon_is_under_attack" then
minetest.sound_play("the_pentagon_is_under_attack", { pos = {x=0, y=0, z=0}, max_hear_distance = 31000, gain = 1.0, })
end


if song == "the_president_is_missing" then
minetest.sound_play("the_president_is_missing", { pos = {x=0, y=0, z=0}, max_hear_distance = 31000, gain = 1.0, })
end


if song == "the_swarm" then
minetest.sound_play("the_swarm", { pos = {x=0, y=0, z=0}, max_hear_distance = 31000, gain = 1.0, })

end

if song == "tomb" then
minetest.sound_play("tomb", { pos = {x=0, y=0, z=0}, max_hear_distance = 31000, gain = 1.0, })

end

if song == "vanclerie" then
minetest.sound_play("vanclerie", { pos = {x=0, y=0, z=0}, max_hear_distance = 31000, gain = 1.0, })
end
end





function GetRandomSong()
if DataPointMap.MapToPlay == "prison" then
selection = math.random(1,11)
if selection == 1 then
playSong("zombies")
end
if selection == 2 then
playSong("prison")
end
if selection == 3 then
playSong("cell_outbreak")
end
if selection == 4 then
playSong("zombies")
end
if selection == 5 then
playSong("prison")
end
if selection == 6 then
playSong("cell_outbreak")
end

if selection == 7 then
playSong("zombies")
end
if selection == 8 then
playSong("prison")
end
if selection == 9 then
playSong("cell_outbreak")
end
if selection == 10 then
playSong("prison")
end

if selection == 11 then
playSong("surviving_for_a_while")
end
end


if DataPointMap.MapToPlay == "hotel" then
selection = math.random(1,11)
if selection == 1 then
playSong("zombies")
end
if selection == 2 then
playSong("hotel")
end
if selection == 3 then
playSong("hotel")
end
if selection == 4 then
playSong("zombies")
end
if selection == 5 then
playSong("hotel")
end
if selection == 6 then
playSong("hotel")
end

if selection == 7 then
playSong("zombies")
end
if selection == 8 then
playSong("hotel")
end
if selection == 9 then
playSong("hotel")
end
if selection == 10 then
playSong("hotel")
end

if selection == 11 then
playSong("surviving_for_a_while")
end
end

if DataPointMap.MapToPlay == "jungle" then
selection = math.random(1,11)
if selection == 1 then
playSong("zombies")
end
if selection == 2 then
playSong("jungle")
end
if selection == 3 then
playSong("jungle")
end
if selection == 4 then
playSong("jungle")
end
if selection == 5 then
playSong("jungle")
end
if selection == 6 then
playSong("jungle")
end

if selection == 7 then
playSong("zombies")
end
if selection == 8 then
playSong("jungle")
end
if selection == 9 then
playSong("jungle")
end
if selection == 10 then
playSong("jungle")
end

if selection == 11 then
playSong("surviving_for_a_while")
end
end




if DataPointMap.MapToPlay == "campsite" then
selection = math.random(1,11)
if selection == 1 then
playSong("zombies")
end
if selection == 2 then
playSong("campsite")
end
if selection == 3 then
playSong("campsite")
end
if selection == 4 then
playSong("zombies")
end
if selection == 5 then
playSong("campsite")
end
if selection == 6 then
playSong("campsite")
end

if selection == 7 then
playSong("zombies")
end
if selection == 8 then
playSong("campsite")
end
if selection == 9 then
playSong("campsite")
end
if selection == 10 then
playSong("campsite")
end

if selection == 11 then
playSong("surviving_for_a_while")
end
end


if DataPointMap.MapToPlay == "shelter" then
selection = math.random(1,11)
if selection == 1 then
playSong("zombies")
end
if selection == 2 then
playSong("shelter")
end
if selection == 3 then
playSong("shelter")
end
if selection == 4 then
playSong("zombies")
end
if selection == 5 then
playSong("shelter")
end
if selection == 6 then
playSong("shelter")
end

if selection == 7 then
playSong("zombies")
end
if selection == 8 then
playSong("shelter")
end
if selection == 9 then
playSong("shelter")
end
if selection == 10 then
playSong("shelter")
end

if selection == 11 then
playSong("surviving_for_a_while")
end
end


if DataPointMap.MapToPlay == "tomb" then
selection = math.random(1,11)
if selection == 1 then
playSong("the_swarm")
end
if selection == 2 then
playSong("survival")
end
if selection == 3 then
playSong("tomb")
end
if selection == 4 then
playSong("the_swarm")
end
if selection == 5 then
playSong("survival")
end
if selection == 6 then
playSong("tomb")
end

if selection == 7 then
playSong("the_swarm")
end
if selection == 8 then
playSong("tomb")
end
if selection == 9 then
playSong("tomb")
end
if selection == 10 then
playSong("tomb")
end

if selection == 11 then
playSong("surviving_for_a_while")
end
end





if DataPointMap.MapToPlay == "vanclerie" then
selection = math.random(1,11)
if selection == 1 then
playSong("the_swarm")
end
if selection == 2 then
playSong("survival")
end
if selection == 3 then
playSong("vanclerie")
end
if selection == 4 then
playSong("the_swarm")
end
if selection == 5 then
playSong("survival")
end
if selection == 6 then
playSong("the_president_is_missing")
end

if selection == 7 then
playSong("the_swarm")
end
if selection == 8 then
playSong("vanclerie")
end
if selection == 9 then
playSong("the_president_is_missing")
end
if selection == 10 then
playSong("vanclerie")
end

if selection == 11 then
playSong("surviving_for_a_while")
end
end



if DataPointMap.MapToPlay == "five" then
selection = math.random(1,11)
if selection == 1 then
playSong("the_swarm")
end
if selection == 2 then
playSong("survival")
end
if selection == 3 then
playSong("five")
end
if selection == 4 then
playSong("five")
end
if selection == 5 then
playSong("survival")
end
if selection == 6 then
playSong("the_pentagon_is_under_attack")
end

if selection == 7 then
playSong("the_swarm")
end
if selection == 8 then
playSong("five")
end
if selection == 9 then
playSong("the_pentagon_is_under_attack")
end
if selection == 10 then
playSong("five")
end

if selection == 11 then
playSong("surviving_for_a_while")
end





-- added
end
-- added
end
God bless you.

List of releases:
Minetest Zombies Minigame - viewtopic.php?f=9&t=28442&p=412633#p412633

- > cdb_1d60e1a03f83

User avatar
Blockhead
Member
Posts: 1623
Joined: Wed Jul 17, 2019 10:14
GitHub: Montandalar
IRC: Blockhead256
In-game: Blockhead Blockhead256
Location: Land Down Under
Contact:

Re: Too much memory in use...

by Blockhead » Post

/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂

User avatar
Desour
Member
Posts: 1469
Joined: Thu Jun 19, 2014 19:49
GitHub: Desour
IRC: Desour
In-game: DS
Location: I'm scared that if this is too exact, I will be unable to use my keyboard.

Re: Too much memory in use...

by Desour » Post

No. Minetest never frees its pcm data. => Engine change needed.

But you can load the sounds later with dynamic media, as Blockhead suggested.

Btw. if you want to play a sound globally, just don't specify a position. Then you also don't have to (ab)use stereo sounds.

(Actually, you could also decrease the sample frequency of your sounds to get smaller pcm data.)
he/him; Codeberg; GitHub; ContentDB; public personal TODO list; "DS" is preferred (but often too short)

User avatar
snoopy
Member
Posts: 263
Joined: Thu Oct 20, 2016 16:49
Location: DE, European Union

Re: Too much memory in use...

by snoopy » Post

Hi,

IMO have a look at:

https://content.minetest.net/packages/T ... /ambience/

Have fun with MT.

User avatar
bosapara
Member
Posts: 637
Joined: Fri Apr 07, 2017 08:49

Re: Too much memory in use...

by bosapara » Post

Blockhead wrote:
Sat Jan 28, 2023 01:39
Try dynamic background music
Even "minetest.dynamic_add_media" function will not help, the RAM of clients is increasing exponentially. 10 tracks - 2GB of RAM

DS-minetest already made good work with PR. As far as I understood maintest engine needs to be changed (to remove unused data from RAM)

Explained in this topic

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests