Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8047707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:11:05+00:00 2026-06-05T06:11:05+00:00

I have a Cocoa app with an embedded WebView . I set the window

  • 0

I have a Cocoa app with an embedded WebView. I set the window controller as accessible through JavaScript with the code below.

The problem is that the call to setValue:self forKey:@"console" seems to introduce a memory leak under ARC in a sense that the WebView and window controller are never released after the window was closed.

When I comment out the setValue line the WebView and controller are automatically released when the window is closed.

I tried [self.webView.windowScriptObject removeWebScriptKey:@"console"], but that did not work either.

Code to add the JavaScript object in the window controller:

- (void)webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)windowObject
       forFrame:(WebFrame *)frame {

    if (frame != self.webView.mainFrame) return;

    [self.webView.windowScriptObject setValue:self forKey:WELCOME_WINDOW_JS_NAME];
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T06:11:06+00:00Added an answer on June 5, 2026 at 6:11 am

    Mark,

    You have identified the problem code. What is missing is that you aren’t setting the key to nil when you release the window: setValue: nil forKey: @"console". Do that and all will be well.

    Andrew

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some processing in my Cocoa app that sometimes ends up calling through
I have a Cocoa app that embeds a WebView. I'd like to intercept a
My MacOsX has a Cocoa app with a special controller/window that employs WebKit for
I have a Cocoa App that depends on the main window being a certain
I have a Cocoa app that uses a WebView to display an HTML interface.
I have an agent Cocoa app ( LSUIElement=1 ) that shows a normal window
I have a graphics editing cocoa app on Mac OSX that produces 32 by
I have a very simple Mac Cocoa app that just has a Web View
I have a custom icon file (MyApp.icns) set up for my Cocoa App. How
I recently started programming my first Cocoa app. I have ran into a problem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.