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 - Leak in Android_JNI_SetActivityTitle (SDL_SetWindowTitle)
Summary: Leak in Android_JNI_SetActivityTitle (SDL_SetWindowTitle)
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: *don't know* (show other bugs)
Version: HG 2.0
Hardware: ARM Android (All)
: P2 normal
Assignee: Gabriel Jacobo
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-08 04:44 UTC by Martin Gerhardy
Modified: 2012-05-25 11:45 UTC (History)
1 user (show)

See Also:


Attachments
bug fix (913 bytes, patch)
2012-05-12 07:38 UTC, Gabriel Jacobo
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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