memory leak? when running this code

Need help running MacroQuest2? Ask your questions about how to get things to work on your computer.

Moderator: MacroQuest Developers

van
a lesser mummy
a lesser mummy
Posts: 37
Joined: Mon Jun 24, 2002 1:04 am

memory leak? when running this code

Post by van » Thu Mar 25, 2004 1:28 am

i have huge issues running this script, after 1 hour my fps drops from 50 to 25 this continues to increase till i get 1fps.

unload kill mq fixes it for a short time. also if i camp out of eq and start over again it stays 1fps. Only once I kill mq and restart will it go back to normal

all thats being used durring this time is #Event healtank "heal tank"
and the buff check and wait loop. Rest of the stuff is not when i see the issue.

here is the rats nest of a macro im using, any suggestions?

Code: Select all

|CLERIC TANK.mac

#Event Loading "You have been slain by a"

#Event healtank "heal tank"
#Event healcleric "heal cleric"
#Event healgroup "heal group"
#Event attack "attack this"
#event wait "cleric stop"
#event end "cleric end"

#Event See "You can't see your target" 
#event Fizzle "Your spell fizzles!"
#event follow "cleric follow me" 
#event stopfollow "cleric do not follow me" 
#event Interrupt "Your casting has been interrupted!" 
#event Interrupt "Your spell is interrupted." 
|#event Recover "You haven't recovered yet..." 
|#event Recover "Spell recovery time not yet met." 
#event Resisted "You target resisted the " 
#event OutOfMana "Insufficient Mana to cast this spell!" 
#event OutOfRange "Your target is out of range, get closer!" 
#event Stunned "You cannot cast while stunned" 
#event Standing "You must be standing to cast a spell" 
#event Collapse "Your gate is too unstable, and collapses." 
#event target "you must first select a target  for this spell" 
#turbo 

Sub Main
/declare mytimer timer 
/varset mytimer 3s
/press esc
/press esc
/call wait

sub attack

/attack on
   :Loop 
      /if n $target(distance)>=20 /sendkey down up 
      /if n $target(distance)>=18 /sendkey down up 
      /if n $target(distance)<=10 /sendkey up up 
      /if n $target(distance)<=8 /sendkey up up 
      /if "$target()"=="TRUE" /if n $target(distance)>=20 /attack on 
      /face fast 
      /face look 
      /doevents 
      /if $char(ability,"Bash")>0 /if n $target(distance)<=15 /if n $v30==0 /doability "Bash" 
      |/if @mytimer==0 
      /if n $char(gem,"Yaulp VI")!=-2 /call castspell 
      /if "$target()"=="TRUE" /goto :Loop 
      /face look 
       /attack off 
      /call wait


      
sub castspell 
/echo Yaulp incoming
/doevent flush 
/sendkey up up
/delay 5
/call cast "Yaulp VI"
/varset mytimer 62s 
/return 

Sub Event_Enraged 
  /varset v30 1 
  /attack off 
  /echo Atk off 
  /sendkey down up 
  /sendkey up up 
  /face 
  /return 


Sub Event_See 
/press down 
/face fast 
/press down 
/return 

Sub Event_Offrage 
   /attack on 
   /return 

Sub Event_Gain 
   /attack off 
   /endmacro keep keys 

Sub Event_Loading 
   /endmacro keep keys 




Sub Event_healtank
/attack off
/echo healing tank
/doevents flush 
/sendkey up up 
/delay 5 
/sendkey up up
/target tank
/delay 5
/call cast "complete healing"
/delay 14 
/call wait



Sub Event_healcleric
/echo healing cleric
/doevents flush 
/sendkey up up 
/delay 5 
/sendkey up up
/target myself
/delay 5
/call cast "supernal elixir"
/delay 14 
/return


Sub Event_healgroup
/echo healing group
/g healing group stay close
/doevents flush 
/sendkey up up 
/delay 5 
/sendkey up up
/target myself
/delay 5
/call cast "word of replenishment"
/delay 14 
/return


Sub Event_attack
/assist tank

/call attack

Sub Event_stopfollow
/attack off

:waitloop
/echo stoping follow
/delay 5
/press left
/doevents
/call wait



Sub Event_follow
/attack off

:waitloop
/echo waiting for commands
/delay 5
/target tank
/delay 5
/follow
/doevents
/call wait

Sub wait
/attack off
:waitloop2
/echo waiting for commands
/delay 5
/doevents
/goto :waitloop2



Sub Event_end
/echo stoping 
/endmacro



Sub Cast(SpellName) 
  /if n $char(gem,"@SpellName")==0 /return CAST_UNKNOWNSPELL 
  :StartCast 
  /if n $char(gem,"@SpellName")<0 /call WaitForRefresh "@SpellName" 
  /cast "@SpellName" 

|  :WaitCast 
|     /call ClearReturnValue 
|     /doevents Fizzle 
|     /doevents Interrupt 
|     /doevents Recover 
|     /doevents Standing 
|     /doevents OutOfRange 
|     /doevents OutOfMana 
|     /doevents Resisted 
|    /if n $return==CAST_RESTART /goto :StartCast 
|     /if n $return>=CAST_RESTART /return $return 

| /if "$char(casting)"=="TRUE" /goto :WaitCast 

/return CAST_SUCCESS 

Sub WaitForRefresh(SpellName) 
|   :LoopWaitForRefresh 
|      /delay 0 
|  /if n $char(gem,"@SpellName")<0 /goto :LoopWaitForRefresh 
/return 

Sub ClearReturnValue 
/return CAST_SUCCESS 

Sub Event_Fizzle 
/return CAST_RESTART 

Sub Event_Interrupt 
/return CAST_RESTART 

Sub Event_Recover 
   /delay 5 
/return 

Sub Event_Standing 
   /stand 
/return CAST_RESTART 

Sub Event_Collapse 
/return CAST_RESTART 

Sub Event_OutOfMana 
/return CAST_OUTOFMANA 

Sub Event_Select 
/endmacro keep keys 

Sub Event_OutOfRange 
/return CAST_OUTOFRANGE 

Sub Event_Stunned 
/return CAST_STUNNED 

Sub Event_Resisted 
/return CAST_RESISTED 
Sub Event_Stunned 
   /varset CastStatus CAST_STUNNED 
/return 

Sub Event_Resisted 
   /varset CastStatus CAST_RESISTED 
/return 

Virtuoso65
a hill giant
a hill giant
Posts: 150
Joined: Wed Oct 15, 2003 2:29 pm

Post by Virtuoso65 » Thu Mar 25, 2004 2:28 am

Well for starters this is in the wrong forum but other then that it is missing stuff or is using redundent commands.

First, you do not need to use "look" or "fast" with face command it defaults to fast and look.

Second, your memory leak could very well be the lack of /return after some of your subs. The /return sends the code parser back to where it jumped from to the sub from in the first place. With out a return the parser will keep scanning down the code untill it hits a return.

Thirdly, the code posted here has alot of upper and lower case starting letters where they shouldnt be. Stay consistant or you might end up making the code parser skip something because the function is case sensitive.

Good day

Caladine
a hill giant
a hill giant
Posts: 164
Joined: Fri Feb 13, 2004 9:29 pm

Post by Caladine » Thu Mar 25, 2004 3:09 am

Yeah, your problem is the fact that you don't return from a whole bunch of your subs. You just /call wait again. What this does over a long period of time is stack a whole lot of /call wait's on your return stack along with any of the sub_EVENTs that you also never /return from. Bang, your memory leak.

My recommendation - recode this so that you always return from your subroutines, and NEVER use /doevents in a sub_EVENT. Have sub_EVENTs set flags that you have a SINGLE main loop check after a /doevents to see what event just occured to choose a course of action.

daerck
a ghoul
a ghoul
Posts: 134
Joined: Mon Jan 12, 2004 8:44 pm

Post by daerck » Thu Mar 25, 2004 5:55 am

First, you do not need to use "look" or "fast" with face command it defaults to fast and look.
No and yes. It doesn't default to fast, but does default to look. Additionally, you can add multiple arguements to look, i.e. /face fast nolook loc 100,200

van
a lesser mummy
a lesser mummy
Posts: 37
Joined: Mon Jun 24, 2002 1:04 am

Post by van » Thu Mar 25, 2004 12:39 pm

sorry for posting it in the wrong forum but i thought it was the correct one as i did not realize the call would do that..

guess its time to write it out correctly this time.

thanks

Sensay
orc pawn
orc pawn
Posts: 26
Joined: Thu Dec 11, 2003 12:06 am
Location: VA
Contact:

little thing..

Post by Sensay » Mon Mar 29, 2004 1:43 am

Code: Select all

#Event Loading "You have been slain by a" 

May wanna take out the " a " part, not all mobs start with " a " =P

Code: Select all

#Event Loading "You have been slain by " 
should be OK