Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

many scheduleUpdate() call without corresponding unscheduleUpdate() make hashkey "leak" #10003

Open
herojia2021 opened this issue Jan 14, 2015 · 0 comments

Comments

@herojia2021
Copy link

in cocos3.2 there are many scheduleUpdate() call without corresponding unscheduleUpdate() ,

if you don't call unscheduleUpdate(), the _hashForUpdate in Scheduler will keep the hash pair forever.

i don't know in normal situation this will make problem or not. but in my situation this make problem.

i notice this because i always got :

            "warning: you CANNOT change update priority in scheduled function"

in console output. if you got this warning then function goes "return;"
this mean the target you call scheduleUpdate() is fail to add update() to _updates0List.
and this also mean your target will never call its update();

。in normal situation, u don't get the warning msg. just leave the key in hash. once you new a node , if system give you the address same with key. and u call scheduleUpdate with this node. In function schedulePerFrame statement goes:

            // will be added again outside if (hashElement).
            unscheduleUpdate(target);

this mean it clear the leak key and says it will added what you want after. its true. but still a very little probability, the dirty priority == priority make statement:

            if ((*hashElement->list)->priority != priority) 

become false. then unscheduleUpdate() not call and return. the schedule still fail.

。in my situation, i use a schedule function to create a node with scheduleUpdate in initialize().
because the create is in a schedule function, this function will call in scheduler::update(),
this make expression:

            if (_updateHashLocked)

become true and get the warning message. and make schedule fail. additionally the warning message is not match with situation we meet. we had not change the priority.

situation2 is easy to happen.
for example
if you use action "CallFunc" to create a Fx obj. and the Fx need scheduleUpdate to do something.
or
if you use spine as your animation system. spine use update function to trigger event system.
you spawn Fx obj in event, again, the Fx need update() to do something.

the key is

  1. you had create a nodeA at addressA which will call scheduleUpdate().
  2. the nodeA is destroy, and because of not calling unscheduleUpdate(), it leave addressA in hash
  3. you have a functionB will call by schedule::update and functionB will create nodeB, and system give you nodeB at addressA, and nodeB call scheduleUpdate();

i think pair unscheduleUpdate with scheduleUpdate() fix some problem. but there is a more complex

way to goes the warning message. i will describe in another issue.

@walzer walzer modified the milestones: unplanned, unconfirmed Apr 27, 2015
@minggo minggo removed this from the unconfirmed milestone Aug 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants