Skip to content

[JENKINS-73090] OOME from LineTransformationOutputStream processing CR-delimited output #16424

@jenkins-infra-bot

Description

@jenkins-infra-bot

A CloudBees CI user reported an OutOfMemoryError on a particular controller. Examination of the heap dump revealed multiple byte arrays in the 1Gb range containing text from running builds; much of the text was of the form of thousands of lines like

Checking out files:  25% (2345/34567)

terminated by CR (ASCII 13). These seem to have been caused by a Windows agent cloning a gigantic Git repository; I was able to confirm in Windows 10 that

node('windows') {
    bat 'dir'
    deleteDir()
    bat 'git clone https://github.com/jenkinsci/jenkins'
}

does produce a bunch of lines of this type. In a real terminal the CR would cause the progress bar to update live on a single line. While the manual page for git-clone says that --progress is implied only when Git is connected to a terminal, and that works as claimed on Linux, I suppose this code does not work in Windows, and you actually need to pass -q.

Currently LineTransformationOutputStream does not treat CR specially (except for purposes of trimEOL) and so it buffers all of the output until the command completes. While the lack of live progress messages is at most an annoyance, if the output is large it can lead to heap exhaustion.


Originally reported by jglick, imported from: OOME from LineTransformationOutputStream processing CR-delimited output
  • assignee: jglick
  • status: Closed
  • priority: Minor
  • component(s): core
  • label(s): performance
  • resolution: Fixed
  • resolved: 2024-05-20T18:59:28+00:00
  • votes: 0
  • watchers: 1
  • imported: 2025-11-24
Raw content of original issue

A CloudBees CI user reported an OutOfMemoryError on a particular controller. Examination of the heap dump revealed multiple byte arrays in the 1Gb range containing text from running builds; much of the text was of the form of thousands of lines like

Checking out files:  25% (2345/34567)

terminated by CR (ASCII 13). These seem to have been caused by a Windows agent cloning a gigantic Git repository; I was able to confirm in Windows 10 that

node('windows') {
    bat 'dir'
    deleteDir()
    bat 'git clone https://github.com/jenkinsci/jenkins'
}

does produce a bunch of lines of this type. In a real terminal the CR would cause the progress bar to update live on a single line. While the manual page for git-clone says that --progress is implied only when Git is connected to a terminal, and that works as claimed on Linux, I suppose this code does not work in Windows, and you actually need to pass -q.

Currently LineTransformationOutputStream does not treat CR specially (except for purposes of trimEOL) and so it buffers all of the output until the command completes. While the lack of live progress messages is at most an annoyance, if the output is large it can lead to heap exhaustion.

Metadata

Metadata

Assignees

No one assigned

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions