Skip to content

[Bug]: Upload log function Out of Memory #1502

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
2 of 3 tasks
CeesJanNolen opened this issue May 24, 2025 · 3 comments
Open
2 of 3 tasks

[Bug]: Upload log function Out of Memory #1502

CeesJanNolen opened this issue May 24, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@CeesJanNolen
Copy link

Required Reading

  • Confirmed

Plugin Version

4.16.6

Flutter Doctor

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.27.1, on Microsoft Windows [Version 10.0.19045.5854], locale nl-NL)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[√] Chrome - develop for the web
[!] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.2.6)
    X Visual Studio is missing necessary components. Please re-run the Visual Studio installer for the "Desktop
      development with C++" workload, and include these components:
        MSVC v142 - VS 2019 C++ x64/x86 build tools
         - If there are multiple build tool versions available, install the latest
        C++ CMake tools for Windows
        Windows 10 SDK
[√] Android Studio (version 2021.3)
[√] Android Studio (version 2024.1)
[√] IntelliJ IDEA Ultimate Edition (version 2022.3)
[√] IntelliJ IDEA Ultimate Edition (version 2024.1)
[√] VS Code, 64-bit edition (version 1.87.0)
[√] Connected device (3 available)
[√] Network resources

Mobile operating-system(s)

  • iOS
  • Android

Device Manufacturer(s) and Model(s)

Motorola Edge 50 Neo

Device operating-systems(s)

Android 15

What happened?

Upon uploading the log generated by the plugin, we got the following error.

Fatal Exception: java.lang.OutOfMemoryError: Failed to allocate a 183500808 byte allocation with 100663296 free bytes and 165MB until OOM, target footprint 195945824, growth limit 268435456
at java.util.Arrays.copyOf(Arrays.java:3585)
at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:177)
at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:543)
at java.lang.StringBuffer.append(StringBuffer.java:319)
at com.transistorsoft.locationmanager.logger.TSLogReader.getLog(:249)
at com.transistorsoft.locationmanager.logger.a.run(SourceFile:29)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1012)

Our app has a button, which allows the user to upload the log to our server for debug purposes. However the app hang and crashed when clicking it. Most likely to the fact that it got out of memory.
Is there a way to upload in chunks or work around this?

Any help would be greatly appreciated! Thanks!

Plugin Code and/or Config

backgroundLocatorSetup = bg.BackgroundGeolocation.ready(
      bg.Config(
        reset: true,
        // Logging & Debug
        debug: false,
        logLevel:
            kDebugMode ? bg.Config.LOG_LEVEL_VERBOSE : bg.Config.LOG_LEVEL_INFO,

        isMoving: true,
        allowIdenticalLocations: true,
        //update every second
        locationUpdateInterval: 1000,

        // Geolocation options
        desiredAccuracy: bg.Config.DESIRED_ACCURACY_HIGH,
        activityType: bg.Config.ACTIVITY_TYPE_OTHER_NAVIGATION,

        //set to 0 to get an update every second
        distanceFilter: 0.0,
        disableElasticity: true,
        locationAuthorizationRequest: "WhenInUse",

        // Activity recognition options
        stopTimeout: 60,
        stopOnStationary: false,
        locationTimeout: 600,
        disableStopDetection: true,
        pausesLocationUpdatesAutomatically: false,
        backgroundPermissionRationale: bg.PermissionRationale(
          title: RallyStrings.getPermissionLabel('title'),
          message: RallyStrings.getPermissionLabel('message'),
          positiveAction: RallyStrings.getPermissionLabel('positive_action'),
          negativeAction: RallyStrings.getPermissionLabel('negative_action'),
        ),
        notification: bg.Notification(
          title: "Route active",
          channelName: "Location tracking",
          text: "Track location in background",
        ),

        // HTTP & Persistence
        autoSync: true,
        maxBatchSize: 100,
        batchSync: true,
        autoSyncThreshold: 50,
        params: {
          "user_id": SharedPrefs.instance.getEmail(),
        },
        url: SharedPrefs.instance.getLocationLogUrl(),
        headers: {
          "app": flavorConf.appTitle.toLowerCase(),
        },

        // Application options
        stopOnTerminate: false,
        startOnBoot: true,
        
        heartbeatInterval: 60,
        preventSuspend: true,
        logMaxDays: 3,
      ),
    );

Relevant log output

@CeesJanNolen CeesJanNolen added the bug Something isn't working label May 24, 2025
@christocracy
Copy link
Member

The .uploadLog method accepts a 2nd arg SQLQuery, where you can limit results with start/end datetime.

https://pub.dev/documentation/flutter_background_geolocation/latest/flt_background_geolocation/SQLQuery-class.html

@willemvanleeuwen
Copy link

Hi Chris, thanks for your reply.
We are aware of the 2nd argument to filter on date. However, it is possible that we ask a user to upload the log a few days after they have used the app. In this case, how would we know for which days there is data in the log?

Since we have logMaxDays set on 3, it should not exceed very high volumes, right?

@christocracy
Copy link
Member

Try executing one call to .uploadLog for each day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants