Search for strongly captured references in Xcode
Although it wouldn't necessarily be a retain cycle to capture self in this context:
[[GlobalInstance shared] addBlock:^
[self doSomething];
];
How would you search for occurrences of self
being captured in blocks using Xcode? Grep would also be an idea I guess :)
ios xcode
add a comment |
Although it wouldn't necessarily be a retain cycle to capture self in this context:
[[GlobalInstance shared] addBlock:^
[self doSomething];
];
How would you search for occurrences of self
being captured in blocks using Xcode? Grep would also be an idea I guess :)
ios xcode
add a comment |
Although it wouldn't necessarily be a retain cycle to capture self in this context:
[[GlobalInstance shared] addBlock:^
[self doSomething];
];
How would you search for occurrences of self
being captured in blocks using Xcode? Grep would also be an idea I guess :)
ios xcode
Although it wouldn't necessarily be a retain cycle to capture self in this context:
[[GlobalInstance shared] addBlock:^
[self doSomething];
];
How would you search for occurrences of self
being captured in blocks using Xcode? Grep would also be an idea I guess :)
ios xcode
ios xcode
asked Nov 12 '18 at 23:15
COOKIESCOOKIES
11210
11210
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
The only thing that matters is whether you have a retain cycle that causes a leak. Strategies for finding leaks include:
Implement deinit to log and watch the console.
Run under Leaks instrument.
Use the Memory Graph.
Howdy @matt. Love your books!! :) Now, you're kinda assuming that I'm looking for a search query that I could use in finding retain cycles -- that's not the case. My question is simply, how would you best find references ofself
within any given block? I.e, blocks that don't referenceself
on the first line, but maybe the last?
– COOKIES
Nov 12 '18 at 23:25
But I’m suggesting that’s not a useful thing to look for. :)
– matt
Nov 12 '18 at 23:30
Lol :D Oh, but I insist :D Kidding aside, here's a scenario; Say you stumbled upon a huge code base that have successfully suppressed compiler warnings by confusing the heck out of it, and you'd want to clean up some cycles - what would be a quick way to get the approximate number of occurrences whereself
is captured in any block -- so I could further filter them out by hand. I.e, I don't expect any answer to this question to plug into AST/Clang/SourceKit and actually verify the leak, instead, simply getting a rough draft list of whereself
is captured would butter my biscuit.
– COOKIES
Nov 12 '18 at 23:46
Also, since I have one of the best authors of iOS on the line - would you mind giving your expertise on the following scenario? Say you have a home page menu VC that referencesself
in a block like above. Say that the block is async - and there's no telling on when it'll call. Wouldn't it be safer to apply the weak/strong dance here, as the user could switch pages from a navigation menu, and potentially allocate more than one home page VC - which would potentially have catastrophic consequences?
– COOKIES
Nov 12 '18 at 23:57
1
Yes, perhaps, but I still think the best thing to do is what my answer suggests, namely caveman debugging to track allocation and deallocation of view controllers and other dubious objects as the app runs.
– matt
Nov 13 '18 at 0:12
|
show 2 more comments
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53271470%2fsearch-for-strongly-captured-references-in-xcode%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The only thing that matters is whether you have a retain cycle that causes a leak. Strategies for finding leaks include:
Implement deinit to log and watch the console.
Run under Leaks instrument.
Use the Memory Graph.
Howdy @matt. Love your books!! :) Now, you're kinda assuming that I'm looking for a search query that I could use in finding retain cycles -- that's not the case. My question is simply, how would you best find references ofself
within any given block? I.e, blocks that don't referenceself
on the first line, but maybe the last?
– COOKIES
Nov 12 '18 at 23:25
But I’m suggesting that’s not a useful thing to look for. :)
– matt
Nov 12 '18 at 23:30
Lol :D Oh, but I insist :D Kidding aside, here's a scenario; Say you stumbled upon a huge code base that have successfully suppressed compiler warnings by confusing the heck out of it, and you'd want to clean up some cycles - what would be a quick way to get the approximate number of occurrences whereself
is captured in any block -- so I could further filter them out by hand. I.e, I don't expect any answer to this question to plug into AST/Clang/SourceKit and actually verify the leak, instead, simply getting a rough draft list of whereself
is captured would butter my biscuit.
– COOKIES
Nov 12 '18 at 23:46
Also, since I have one of the best authors of iOS on the line - would you mind giving your expertise on the following scenario? Say you have a home page menu VC that referencesself
in a block like above. Say that the block is async - and there's no telling on when it'll call. Wouldn't it be safer to apply the weak/strong dance here, as the user could switch pages from a navigation menu, and potentially allocate more than one home page VC - which would potentially have catastrophic consequences?
– COOKIES
Nov 12 '18 at 23:57
1
Yes, perhaps, but I still think the best thing to do is what my answer suggests, namely caveman debugging to track allocation and deallocation of view controllers and other dubious objects as the app runs.
– matt
Nov 13 '18 at 0:12
|
show 2 more comments
The only thing that matters is whether you have a retain cycle that causes a leak. Strategies for finding leaks include:
Implement deinit to log and watch the console.
Run under Leaks instrument.
Use the Memory Graph.
Howdy @matt. Love your books!! :) Now, you're kinda assuming that I'm looking for a search query that I could use in finding retain cycles -- that's not the case. My question is simply, how would you best find references ofself
within any given block? I.e, blocks that don't referenceself
on the first line, but maybe the last?
– COOKIES
Nov 12 '18 at 23:25
But I’m suggesting that’s not a useful thing to look for. :)
– matt
Nov 12 '18 at 23:30
Lol :D Oh, but I insist :D Kidding aside, here's a scenario; Say you stumbled upon a huge code base that have successfully suppressed compiler warnings by confusing the heck out of it, and you'd want to clean up some cycles - what would be a quick way to get the approximate number of occurrences whereself
is captured in any block -- so I could further filter them out by hand. I.e, I don't expect any answer to this question to plug into AST/Clang/SourceKit and actually verify the leak, instead, simply getting a rough draft list of whereself
is captured would butter my biscuit.
– COOKIES
Nov 12 '18 at 23:46
Also, since I have one of the best authors of iOS on the line - would you mind giving your expertise on the following scenario? Say you have a home page menu VC that referencesself
in a block like above. Say that the block is async - and there's no telling on when it'll call. Wouldn't it be safer to apply the weak/strong dance here, as the user could switch pages from a navigation menu, and potentially allocate more than one home page VC - which would potentially have catastrophic consequences?
– COOKIES
Nov 12 '18 at 23:57
1
Yes, perhaps, but I still think the best thing to do is what my answer suggests, namely caveman debugging to track allocation and deallocation of view controllers and other dubious objects as the app runs.
– matt
Nov 13 '18 at 0:12
|
show 2 more comments
The only thing that matters is whether you have a retain cycle that causes a leak. Strategies for finding leaks include:
Implement deinit to log and watch the console.
Run under Leaks instrument.
Use the Memory Graph.
The only thing that matters is whether you have a retain cycle that causes a leak. Strategies for finding leaks include:
Implement deinit to log and watch the console.
Run under Leaks instrument.
Use the Memory Graph.
answered Nov 12 '18 at 23:21
mattmatt
324k45523723
324k45523723
Howdy @matt. Love your books!! :) Now, you're kinda assuming that I'm looking for a search query that I could use in finding retain cycles -- that's not the case. My question is simply, how would you best find references ofself
within any given block? I.e, blocks that don't referenceself
on the first line, but maybe the last?
– COOKIES
Nov 12 '18 at 23:25
But I’m suggesting that’s not a useful thing to look for. :)
– matt
Nov 12 '18 at 23:30
Lol :D Oh, but I insist :D Kidding aside, here's a scenario; Say you stumbled upon a huge code base that have successfully suppressed compiler warnings by confusing the heck out of it, and you'd want to clean up some cycles - what would be a quick way to get the approximate number of occurrences whereself
is captured in any block -- so I could further filter them out by hand. I.e, I don't expect any answer to this question to plug into AST/Clang/SourceKit and actually verify the leak, instead, simply getting a rough draft list of whereself
is captured would butter my biscuit.
– COOKIES
Nov 12 '18 at 23:46
Also, since I have one of the best authors of iOS on the line - would you mind giving your expertise on the following scenario? Say you have a home page menu VC that referencesself
in a block like above. Say that the block is async - and there's no telling on when it'll call. Wouldn't it be safer to apply the weak/strong dance here, as the user could switch pages from a navigation menu, and potentially allocate more than one home page VC - which would potentially have catastrophic consequences?
– COOKIES
Nov 12 '18 at 23:57
1
Yes, perhaps, but I still think the best thing to do is what my answer suggests, namely caveman debugging to track allocation and deallocation of view controllers and other dubious objects as the app runs.
– matt
Nov 13 '18 at 0:12
|
show 2 more comments
Howdy @matt. Love your books!! :) Now, you're kinda assuming that I'm looking for a search query that I could use in finding retain cycles -- that's not the case. My question is simply, how would you best find references ofself
within any given block? I.e, blocks that don't referenceself
on the first line, but maybe the last?
– COOKIES
Nov 12 '18 at 23:25
But I’m suggesting that’s not a useful thing to look for. :)
– matt
Nov 12 '18 at 23:30
Lol :D Oh, but I insist :D Kidding aside, here's a scenario; Say you stumbled upon a huge code base that have successfully suppressed compiler warnings by confusing the heck out of it, and you'd want to clean up some cycles - what would be a quick way to get the approximate number of occurrences whereself
is captured in any block -- so I could further filter them out by hand. I.e, I don't expect any answer to this question to plug into AST/Clang/SourceKit and actually verify the leak, instead, simply getting a rough draft list of whereself
is captured would butter my biscuit.
– COOKIES
Nov 12 '18 at 23:46
Also, since I have one of the best authors of iOS on the line - would you mind giving your expertise on the following scenario? Say you have a home page menu VC that referencesself
in a block like above. Say that the block is async - and there's no telling on when it'll call. Wouldn't it be safer to apply the weak/strong dance here, as the user could switch pages from a navigation menu, and potentially allocate more than one home page VC - which would potentially have catastrophic consequences?
– COOKIES
Nov 12 '18 at 23:57
1
Yes, perhaps, but I still think the best thing to do is what my answer suggests, namely caveman debugging to track allocation and deallocation of view controllers and other dubious objects as the app runs.
– matt
Nov 13 '18 at 0:12
Howdy @matt. Love your books!! :) Now, you're kinda assuming that I'm looking for a search query that I could use in finding retain cycles -- that's not the case. My question is simply, how would you best find references of
self
within any given block? I.e, blocks that don't reference self
on the first line, but maybe the last?– COOKIES
Nov 12 '18 at 23:25
Howdy @matt. Love your books!! :) Now, you're kinda assuming that I'm looking for a search query that I could use in finding retain cycles -- that's not the case. My question is simply, how would you best find references of
self
within any given block? I.e, blocks that don't reference self
on the first line, but maybe the last?– COOKIES
Nov 12 '18 at 23:25
But I’m suggesting that’s not a useful thing to look for. :)
– matt
Nov 12 '18 at 23:30
But I’m suggesting that’s not a useful thing to look for. :)
– matt
Nov 12 '18 at 23:30
Lol :D Oh, but I insist :D Kidding aside, here's a scenario; Say you stumbled upon a huge code base that have successfully suppressed compiler warnings by confusing the heck out of it, and you'd want to clean up some cycles - what would be a quick way to get the approximate number of occurrences where
self
is captured in any block -- so I could further filter them out by hand. I.e, I don't expect any answer to this question to plug into AST/Clang/SourceKit and actually verify the leak, instead, simply getting a rough draft list of where self
is captured would butter my biscuit.– COOKIES
Nov 12 '18 at 23:46
Lol :D Oh, but I insist :D Kidding aside, here's a scenario; Say you stumbled upon a huge code base that have successfully suppressed compiler warnings by confusing the heck out of it, and you'd want to clean up some cycles - what would be a quick way to get the approximate number of occurrences where
self
is captured in any block -- so I could further filter them out by hand. I.e, I don't expect any answer to this question to plug into AST/Clang/SourceKit and actually verify the leak, instead, simply getting a rough draft list of where self
is captured would butter my biscuit.– COOKIES
Nov 12 '18 at 23:46
Also, since I have one of the best authors of iOS on the line - would you mind giving your expertise on the following scenario? Say you have a home page menu VC that references
self
in a block like above. Say that the block is async - and there's no telling on when it'll call. Wouldn't it be safer to apply the weak/strong dance here, as the user could switch pages from a navigation menu, and potentially allocate more than one home page VC - which would potentially have catastrophic consequences?– COOKIES
Nov 12 '18 at 23:57
Also, since I have one of the best authors of iOS on the line - would you mind giving your expertise on the following scenario? Say you have a home page menu VC that references
self
in a block like above. Say that the block is async - and there's no telling on when it'll call. Wouldn't it be safer to apply the weak/strong dance here, as the user could switch pages from a navigation menu, and potentially allocate more than one home page VC - which would potentially have catastrophic consequences?– COOKIES
Nov 12 '18 at 23:57
1
1
Yes, perhaps, but I still think the best thing to do is what my answer suggests, namely caveman debugging to track allocation and deallocation of view controllers and other dubious objects as the app runs.
– matt
Nov 13 '18 at 0:12
Yes, perhaps, but I still think the best thing to do is what my answer suggests, namely caveman debugging to track allocation and deallocation of view controllers and other dubious objects as the app runs.
– matt
Nov 13 '18 at 0:12
|
show 2 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53271470%2fsearch-for-strongly-captured-references-in-xcode%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown