Skip to content

improve memory footprint for read operations - #2102

Open
alperozturk96 wants to merge 1 commit into
masterfrom
improve-oome-read-data
Open

improve memory footprint for read operations#2102
alperozturk96 wants to merge 1 commit into
masterfrom
improve-oome-read-data

Conversation

@alperozturk96

Copy link
Copy Markdown
Collaborator

Changes

  • Catches OOME
  • Read only once remoteData.getResponses();

Signed-off-by: alperozturk96 <alper_ozturk@proton.me>
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

SpotBugs

CategoryBaseNew
Bad practice3131
Correctness2828
Dodgy code1414
Internationalization66
Malicious code vulnerability2626
Multithreaded correctness77
Performance77
Security44
Total123123

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reduces repeated WebDAV response-array access and attempts to improve memory behavior when parsing folder listings (regular files, trashbin, and versions) in the legacy owncloud remote operations.

Changes:

  • Cache remoteData.getResponses() into a local MultiStatusResponse[] to avoid repeated calls during parsing.
  • Pre-size ArrayList instances based on the number of WebDAV responses to reduce resizing overhead.
  • Add an OutOfMemoryError catch in ReadFolderRemoteOperation to return a failure instead of crashing.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
library/src/main/java/com/owncloud/android/lib/resources/trashbin/ReadTrashbinFolderRemoteOperation.java Cache responses array and pre-size result list while iterating trashbin entries.
library/src/main/java/com/owncloud/android/lib/resources/files/ReadFolderRemoteOperation.java Cache responses array, pre-size list, and add an OutOfMemoryError catch during folder reads.
library/src/main/java/com/owncloud/android/lib/resources/files/ReadFileVersionsRemoteOperation.java Cache responses array and pre-size versions list while iterating version entries.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

private void readData(MultiStatus remoteData, OwnCloudClient client) {
folderAndFiles = new ArrayList<>();
MultiStatusResponse[] responses = remoteData.getResponses();
folderAndFiles = new ArrayList<>(responses.length);
Comment on lines +84 to +87
} catch (OutOfMemoryError e) {
mFolderAndFiles = null;
result = new RemoteOperationResult(
new Exception("Not enough memory to read the contents of " + mRemotePath, e));
private void readData(MultiStatus remoteData, OwnCloudClient client) {
versions = new ArrayList<>();
MultiStatusResponse[] responses = remoteData.getResponses();
versions = new ArrayList<>(responses.length);
@nextcloud-android-bot

Copy link
Copy Markdown
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants