17

I started using Google Play Game Services a while ago, and yesterday while checking the logcat I couldnt help to notice this error:

E/DataBuffer(3183): Internal data leak within a DataBuffer object detected! Be sure to explicitly call close() on all DataBuffer extending objects when you are done with them. (internal object: com.google.android.gms.common.data.DataHolder@40555410)

It occurs several times in a row. Im not exactly sure why it arises. It doesnt make my app crash nor makes the google achievement/leaderboards functionality stop working.

All I know is that it is related to the functions "unlockAchievementImmediate" and "submitScoreImmediate".

Has anybody encountered this problem before or has any suggestions?


Edit: In my app I only use "unlockAchievementImmediate" and "submitScoreImmediate". These functions don't return any buffers that need any closing.

cavpollo
  • 4,071
  • 2
  • 40
  • 64
  • This is also occurring when I use the onStateLoadedListener of the AppStateClient (which has been fun, since no Buffer object is even returned, so not sure how Google expects me to close it!) – user2346305 Feb 12 '14 at 01:49

2 Answers2

7

These items extend DataBuffer: AchievementBuffer, AppStateBuffer, FilteredDataBuffer, GameBuffer, InvitationBuffer, LeaderboardBuffer, LeaderboardScoreBuffer, MetadataBuffer, MomentBuffer, ParticipantBuffer, PersonBuffer, PlayerBuffer, TurnBasedMatchBuffer.

These are generally found in your listeners of those particular items. For example:

public void onTurnBasedMatchesLoaded(int statusCode, LoadMatchesResponse response) 
{
    TurnBasedMatchBuffer buff = response.getMyTurnMatches();
    // do some stuff with buff
    buff.close()
}

public void onPlayersLoaded(int statusCode, PlayerBuffer buff) 
{
    Player p = buff.get(0);
    buff.close();
}

The error doesn't report until after I exit my app and re-enter. If I call up my matches 3 times and exit the app without calling buff.close(), I can expect to see the warning 3 times upon opening it back up again. Add in the buff.close() and they disappear. Voila!

CodeMonkey
  • 1,795
  • 3
  • 16
  • 46
  • While the above is still correct, I do still find that I have a rogue one somewhere which I cannot account for with any unclosed Buffers... It seems that simply signing in, exiting, and reopening is enough to cause this one. Perhaps the jars we're implementing are causing it. – CodeMonkey Feb 18 '14 at 01:51
  • It may be the case for Multiplayer/TurnBasedMatches functions, but in my app I only use "unlockAchievementImmediate" and "submitScoreImmediate", which dont return any buffers. – cavpollo Feb 18 '14 at 20:45
1

Any SubClass of Data Buffer needs to be released. So after you are done with that object release it.

Data Buffer object contains a release() method so after you are done with that object just release it using databuffer.release();.

Ivar
  • 6,138
  • 12
  • 49
  • 61
  • At the time I was developing the app (I dont know if anything has changed since then), I only used the methods "unlockAchievementImmediate" and "submitScoreImmediate". These functions didn't return any buffers so there wasn't anything that could be released. – cavpollo Oct 25 '16 at 17:40