1. Hey! Guest! The 33rd GMC Jam will take place between May 23rd, 12:00 UTC (Friday noon) and May 27th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

Sound_delete causing game to crash?

Discussion in 'Programming' started by LV154, Mar 13, 2019.

  1. LV154

    LV154 Member

    Joined:
    Sep 9, 2016
    Posts:
    43
    Dear all,

    My project is a top down shooter that involves loading and unloading external sounds whilst driving a car. Sometimes, but not always, the game freezes and crashes without a fatal error when I exit a vehicle. Usually, the looping song stops, but I would occasionally notice that the sound carries on playing after I exit a vehicle, then a fraction of a second later the entire game freezes and crashes with no message.

    When the player exits a vehicle, an alarm is initiated to the car parent object which involves the following:

    .....code to create the player if place is free etc.....
    if sound_exists(radio){
    sound_stop(radio){
    sound_delete(radio){radio=0}}}

    I've put in sound_stop before sound delete thinking this would solve the problem but it still persists.

    I'm not sure whether this is an issue with memory, as the last time this has happened the memory wasn't exactly full. Perhaps I'm missing something out here, or looking in the wrong place altogether? Am I asking the computer to do way too many things too quickly?

    I really appreciate any input, perhaps some of you know more about game processes more than I do.

    Thanks
     
  2. IndianaBones

    IndianaBones Member

    Joined:
    Jul 5, 2016
    Posts:
    2,054
    What version of Game Maker are you using? It doesn't seem to be part of GMS 2, and in the GMS 1.4 docs it says:
    sound_delete() removes the sound from your game memory and resources totally until you restart the game completely.

    Is that your intention with this code?
     
  3. LV154

    LV154 Member

    Joined:
    Sep 9, 2016
    Posts:
    43
    Thanks for the reply. Yeah, as the radio wouldn't be needed if the player is on foot. It's an external sound that is loaded into memory every time the player enters a vehicle or changes the radio station.
     
  4. Alexx

    Alexx Member

    Joined:
    Jun 21, 2016
    Posts:
    395
    How many MB is the file?
     
  5. LV154

    LV154 Member

    Joined:
    Sep 9, 2016
    Posts:
    43
    The exe itself is approximately 15mb. the largest sound file is 1.6mb, while the average is 500kb

    I think it's worth noting that, according to task manager, the game takes up 450mb of memory. This is quite high, but the game is more or less complete and involves a lot of external resources.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice