1

I am facing java.lang.OutOfMemoryError in React Native android platform while WatermelonDB sync pull api call. I have checked the API response size in Postman, getting 125 MB. The android app is crashing but IOS App working fine.

I am using Axios GET in the watermelonDB sync pullChanges function.

I have already tried adding in the manifest file

android:hardwareAccelerated="false" , 
android:largeHeap="true". 

But, it didn't work in my case.

Error: java.lang.OutOfMemoryError: Failed to allocate a 262240856 byte allocation with 25165824 free bytes and 192MB until OOM, target footprint 427490784, growth limit 603979776

Here is my Code Sample:

const pullChanges = async ({ lastPulledAt, schemaVersion, migration }: any) => {
    const userId = await getActiveUserId();
    const syncPullUrl = `BACKEND APIURL`;
    const params = { lastPulledAt, userId, schemaVersion, migration };
    const response = await axios.get(syncPullUrl, { params: params, timeout: 900000 });
    if (response.status === 200) {
       const responseData = await response.data;
        const { changes, timestamp } = responseData.data;
        return { changes, timestamp };
    } else {
        return { changes: {}, timestamp: null };
    }

}

export default pullChanges;

Any suggestion or help highly appreciated. Thanks!

Diptesh Atha
  • 851
  • 8
  • 18

0 Answers0