Open jsonchi opened 7 years ago
which method do you use to measure? I remember if you hold sContext
as static, that will cause memory leaks.
@jsonchi I think cocos2d-x isn't supposed to be a multi activity app. Because of that the
private static Cocos2dxActivity sContext = null;
was implemented to be useable with
public static Context getContext() {
return sContext;
}
The only possible way, I see right now, is to clear the sContext value by yourself, if you close the activity.
PS: Just an idea, would it be possible to set the variable in onStart and clear it in onStop? I don't know the the getContext() call is everywhere used within cocos2d-x (without searching all the code).
sContext
is used as static variable is because JNI codes will use the variable, and currently, all native method are static.
Is sContext
the only thing that will cause memory leak?
Open GL drawing state also influenced when re-enter that Activty
I have an Android App which embed Cocos Activity, like most Activities in my App is normal Android Activity except a few of Cocos Activities which inherited from Cocos2dxActivity.
When I quit from Cocos Activity and back to normal Activity,the static field(e.g. sContext) in Cocos2dxActivity can cause memory leaks.
So how I can do to fix this kind of issue?