I tried to make social module for my app, something like wrapper, that will contain Google+,Facebook and twitter integration templates.
Now I am working with Facebook SDK and decided to use LeakCanary in my app, after successful log in I rotated the device few times, and see the following information:
Here is MainActivity.class:
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
setFragment();
}
private void setFragment(){
getSupportFragmentManager()
.beginTransaction()
.add(R.id.container, new MainFragment())
.commit();
}
}
Here is how I log in to Facebook:
public void configureFacebook(@NonNull Fragment fragment,
@Nullable String permissions, @Nullable String requestFields) {
setPermissionAndRequestFields(permissions, requestFields);
loginManager = LoginManager.getInstance();
callbackManager = CallbackManager.Factory.create();
loginManager.registerCallback(callbackManager, facebookCallback);
loginManager.logInWithReadPermissions(fragment, Arrays.asList(this.permissions));
loginManager=null;
}
I tried log in using Login Button too, in this case I catch this issue and new one, with following info:
Here is how I log in using LoginButton.class:
public void configureFacebook(@NonNull Fragment fragment,
@Nullable String permissions, @Nullable String requestFields, @NonNull LoginButton button) {
callbackManager = CallbackManager.Factory.create();
setFbButton(button);
setPermissionAndRequestFields(permissions, requestFields);
fbButton.setFragment(fragment);
fbButton.setReadPermissions(this.permissions);
fbButton.registerCallback(callbackManager, facebookCallback);
}
I can't figure out how to fix those issues. What I am doing wrong?
UPDATE: Leak in Facebook Activity.class has been shown without the rotation device.
A memory leak starts when a program requests a chunk of memory from the operating system for itself and its data. As a program operates, it sometimes needs more memory and makes an additional request.
To avoid memory leaks, memory allocated on heap should always be freed when no longer needed.
Memory leaks may not be serious or even detectable by normal means. In modern operating systems, normal memory used by an application is released when the application terminates. This means that a memory leak in a program that only runs for a short time may not be noticed and is rarely serious.
Looks like they may have fixed this for Facebook SDK Version 4.2.0. see here
Updating the Facebook SDK may be the solution to your problem.
I updated it to 4.7.0 and I think this issue has been fixed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With