Skip to content
GitLab
    • GitLab: the DevOps platform
    • Explore GitLab
    • Install GitLab
    • How GitLab compares
    • Get started
    • GitLab docs
    • GitLab Learn
  • Pricing
  • Talk to an expert
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
    Projects Groups Snippets
  • Sign up now
  • Login
  • Sign in / Register
  • Lazarus Lazarus
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 2,112
    • Issues 2,112
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 14
    • Merge requests 14
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • FPC
  • LazarusLazarus
  • LazarusLazarus
  • Issues
  • #35944
Closed
Open
Issue created Aug 09, 2019 by FPC Admin account@fpc_adminOwner

NSView resource leak when using TCustomControl

Original Reporter info from Mantis: zpeterson @boramis
  • Reporter name: Zoë Peterson

Description:

Controls embedded in a TCocoaManualScrollView (TCustomControl) currently leak their NSView handles.

EmbedInManualScrollView is used in two places, TCocoaWSCustomControl.CreateHandle and TCocoaWSCustomSplitter.CreateHandle. Both allocate the base control, call EmbedInManualScrollView, and return the scroll view as the result. At that point, the inner view has a retainCount of 2, one from the alloc.init and one from the scrollview's subview reference. Neither TCocoaWSCustomControl nor TCocoaWSCustomSplitter have DestroyHandle implementations, so the default one runs, which only releases the "Handle" property. The manual scroll view is released and deallocated, but the embedded one still has the outstanding reference. You can verify that by adding logging to the places where TCocoaCustomControl are allocated and in its dealloc; there will be many more alloc calls than dealloc ones.

EmbedInScrollView has an optional parameter (defaults to true) that releases the embedded view after the scroll view is created and the subview is assigned. That keeps the resulting retain count at 1.

This patch adds the same release behavior to EmbedInManualScrollView, though since there isn't anywhere that doesn't want that behavior, I left out making it optional.

As an alternative, TCocoaManaualScrollView could call the release when it's deallocated, or the relevant controls could do it in DestroyHandle. TCocoaSpinEdit does similar embedding and manages the reference counts explicitly in lclReleaseSubcontrols.

Mantis conversion info:

  • Mantis ID: 35944
  • Version: 2.0.3 (SVN)
  • Fixed in revision: 61688 (#0ff8e75f)
Assignee
Assign to
Time tracking