We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1465

Summary: Leak in Android_JNI_SetActivityTitle (SDL_SetWindowTitle)
Product: SDL Reporter: Martin Gerhardy <martin.gerhardy>
Component: *don't know*Assignee: Gabriel Jacobo <gabomdq>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: gabomdq
Version: HG 2.0   
Hardware: ARM   
OS: Android (All)   
Attachments: bug fix

Description Martin Gerhardy 2012-04-08 04:44:23 UTC
Calling SDL_SetWindowTitle in a loop will result in a jvm crash because the jstring for the title is not marked as garbage collactable.


this fixed the issue:

extern "C" void Android_JNI_SetActivityTitle(const char *title)
{
    jmethodID mid;

    mid = mEnv->GetStaticMethodID(mActivityClass,"setActivityTitle","(Ljava/lang/String;)V");
    if (mid) {
    	jstring jtitle = reinterpret_cast<jstring>(mEnv->NewStringUTF(title));
        mEnv->CallStaticVoidMethod(mActivityClass, mid, jtitle);
        mEnv->DeleteLocalRef(jtitle);
    }
}

how to reproduce:
just do a loop with n = 513 and call SDL_SetWindowTitle with different title strings.
Comment 1 Gabriel Jacobo 2012-05-12 07:38:47 UTC
Created attachment 854 [details]
bug fix

I'm attaching your bug fix in patch form so Sam or Ryan can incorporate it more easily. Thanks!
Comment 2 Gabriel Jacobo 2012-05-25 11:45:41 UTC
Fixed in changeset 6048116f40b1