ID:1503933
 
(See the best response by Xirre.)
Code:
                if("Menu Colors")
startloop
switch(src.MenuCheck(list("-Cancel-","Steel","Blood"),0,"Select an Option","Select an Option"))
if("Steel")
src.bgcolor1="#DCDCDC"
if("Blood")
src.bgcolor1="#DE0101"
if("-Cancel-")
return
if(src.ingame<>0||src.delay<>0)
return
else
goto startloop


Problem description:

This uses sd_Alert() by Shadowdarke.

http://www.byond.com/developer/Shadowdarke/sd_Alert

the sd_Alert is initialized like so:
sd_Alert(src, xdesc, xtitle, movelist, xdef,turntimer,0,"225x[min(255+10.37*movelist.len,410)]",,\ "","tagged-[src.menuid]",,SD_ALERT_LINKS)

After about 100 loops, dream seeker starts to freak out with colors disappearing, then after 50 more, dreamseeker.exe crashes.

Here is the crash report:
Faulting application name: dreamseeker.exe, version: 5.0.504.1234, time stamp: 0x5303ca66 Faulting module name: MFC42.DLL, version: 6.6.8064.0, time stamp: 0x4d79b238 Exception code: 0xc0000005 Fault offset: 0x00029cd3 Faulting process id: 0x2454 Faulting application start time: 0x01cf304147065640 Faulting application path: C:\Program Files\BYOND\bin\dreamseeker.exe Faulting module path: C:\Windows\system32\MFC42.DLL Report Id: b1c8c821-9c51-11e3-858f-ccf007029d6e Fault bucket 88120286, type 17 Event Name: APPCRASH Response: Not available Cab Id: 0 Problem signature: P1: dreamseeker.exe P2: 5.0.504.1234 P3: 5303ca66 P4: MFC42.DLL P5: 6.6.8064.0 P6: 4d79b238 P7: c0000005 P8: 00029cd3 P9: P10: Attached files: C:\Users\Evan\AppData\Local\Temp\WER1227.tmp.WERInternalMeta data.xml These files may be available here: \Microsoft\Windows\WER\ReportArchive\AppCrash_dreamseeker.exe _fdf394cebac2e4e5133cb9411871b2b73f442dce_47154bcc Analysis symbol: Rechecking for solution: 0 Report Id: b1c8c821-9c51-11e3-858f-ccf007029d6e Report Status: 0

I'm wondering if this might be a memory leak or something?
I figured out it's a memory leak. The memory being used by dreamseeker.exe is going up with each loop but never going down. Now how to fix it...
Please post this in the bug reports section.

http://www.byond.com/forum/?forum=5

They can help you better there.
Best response
For starters, you shouldn't be using goto.

//Pardon me if there's any misspelling or other typical errors. I'm writing it from scratch, not copying.
var/selecting = 0
selecting = 1 // This is so you can use it on multiple while loops and not just one. Just place it above each while loop like this.
while(selecting)
if("Menu Colors")
switch(src.MenuCheck(list("-Cancel-", "Steel", "Blood"), 0, "Select an Option", "Select an Option:")
if("Steel")
src.bgcolor1 = "#DCDCDC"
if("Blood")
src.bgcolor1 = "#DE0101"
if("-Cancel-")
return
if(src.ingame!=0||src.delay!=0) // I just like != better. Personal preference. You can change it back to <> if you like.
selecting = 0
return


There are many other ways of going about removing that goto. But this way works just fine.

Another thing I saw was that your indentation with if("-Cancel-") is by far off. Same with Steel. I don't know if this was a pasting error or... Yeah.

Not sure if this will help at all, but go ahead and try it.
Well, I might have an inkling. How do I remove an html page from memory?

I believe it might be sd_alert causing the crash. sd_alert is terminated like so:
sd_alert
var
client/target
response
list/validation

Del()
target << browse(null,"window=\ref[src]")
..()


However, my dreamseeker.exe's memory useage is not going down when an sd_alert is terminated, it seems that the menu might be remaining in the cache or memory.

How do I get rid of it from the cache/memory? That's a good place to start I think.

I tried this, but it's not working:
    Del()
target << browse(null,"window=\ref[src]")
target << browse_rsc(null,"\ref[src]")
..()
I've never seen memory go down after deleting. I've already tried forcefully deleting every variable in existence as a test. As long as it's not going from 50MB to 500MB in an hour (or even at all) then it's fine. A few megabytes of an increase is fine.

Try my fix and tell me your results as to whether or not you still encounter a crash. Like I said, you shouldn't be using goto. I've heard it's buggy and outdated.

Edit: I modified the code. I didn't check it thoroughly and came to realize that it would never end. Ever. Forgot to make it set itself back to 0. It's all good now.
Alright. I'll look into purging goto from the code and seeing if that helps. But the cache thing is bugging me since my memory is going from 140k > 240k in about 100 menus. It's a menu-based application. For reference, i won't be using while(selecting) selecting=0, i'll probably use while(1) then use a simple return when I want to kill it.

The BYOND help thing says that there is a way to manually purge files from the cache.


If a resource file is not used for a long time, it will be automatically removed from the cache file to save space. If a cache file gets too bulky, however, you may manually delete it and start from scratch.


I've set my browse() to use a "file=menu" argument yet that's not helping. But since the file being generated is called menu i should be able to purge it somehow, right?
Okay. I figured out a solution. However now I come to a new problem which is probably a byond bug which i'll be making a topic for.

Thanks guys.