Pokemon Go's latest update has tarted problems related to memory stability of the app. The 0.35 update remained unnoticed by numerous blogs, aside from Reddit. There were evidences from Pokemon Go users that show their phone memory's usage, especially when playing above gym level 6. These data have shown that there were lapses on Niantic's programming.
This might be the valid reason why some users are experiencing crashes during gym battles. It can only mean that RAM usage has already exceeded during gym battles, as well as in other functions. Reddit users troxy and conspire_pokemon_go have provided a graph. The graph showed an excessive amount of memory usage when a game sequence was launched. On the Silphroad, user conspire_pokemon_go said that the game's gym stability was highly affected. It was also mentioned on this post that app crashes happen whenever there is an interaction with a gym, especially if a new Pokemon is placed on a newly-raised gym.
According to the reports from Otakukart, when a test was run to check RAM usage during a number of interactions within the Lv. 10 gym, it was noted that the RAM ram usage increased significantly. When the app was freshly booted, it consumed 420 MB. Additionally, first interaction with a Lv. 10 Gym took 449 MB. On second interaction, memory usage increased to 460 MB. Then on the third, it reached 486 MB, and on the fourth interaction, the app crashed. Therefore, it can be seen that gyms have caused issues on memory.
User rabidWeevil posted about the worse memory leaks of update 0.39 and 0.39.1, as compared to 0.37. It was mentioned that there might be a possibility that this memory leak has already been existing, yet it was not just noticed when update 0.39 came. It can't still be pointed out what has changed, but there might be something in it.