Memory is not released during perform batch updates in CollectionViewNavigation Controller not releasing memory, memory leak?How to show images from API in CollectionViewCan't implement required methods of JSQMessagesViewController Swift 3Issues with casting celltypes to dequeueHow to correctly load information from Firebase?Swift Error - Use of undeclared type 'cell' - Collection ViewViewController not released from Memoryuibutton in collectionview cell action duplicatingSwift vertical UICollectionView inside UITableViewMultiple UICollection View on single UIView Scrolling is not working while cell data loading from API
How can I get a player to accept that they should stop trying to pull stunts without thinking them through first?
Was lunar module "pilot" Harrison Schmitt legally a "pilot" at the time?
Should disabled buttons give feedback when clicked?
Does Google Maps take into account hills/inclines for route times?
How to achieve this rough borders and stippled illustration look?
Simple LED driver, transistor and GPIO
Single word for "refusing to move to next activity unless present one is completed."
A pyramid from a square
What does "it kind of works out" mean?
Can fluent English speakers distinguish “steel”, “still” and “steal”?
Is Trump personally blocking people on Twitter?
Does the Dispel Magic spell work on the Mirror Image spell?
Why do players in the past play much longer tournaments than today's top players?
Why do people keep referring to Leia as Princess Leia, even after the destruction of Alderaan?
What would be the ideal melee weapon made of "Phase Metal"?
How might the United Kingdom become a republic?
Novel where a group of scientists in a spaceship encounter various aliens
How do I ask for help/teamwork on tedious tasks that don't require speciality knowledge?
Get ids only where one id is null and other isn't
Why were Er and Onan punished if they were under 20?
Why does the autopilot disengage even when it does not receive pilot input?
Who has taken "my" Managed package namespace? Can we find out?
Book where the stars go black due to aliens stopping human observation collapsing quantum possibilities
Is anyone advocating the promotion of homosexuality in UK schools?
Memory is not released during perform batch updates in CollectionView
Navigation Controller not releasing memory, memory leak?How to show images from API in CollectionViewCan't implement required methods of JSQMessagesViewController Swift 3Issues with casting celltypes to dequeueHow to correctly load information from Firebase?Swift Error - Use of undeclared type 'cell' - Collection ViewViewController not released from Memoryuibutton in collectionview cell action duplicatingSwift vertical UICollectionView inside UITableViewMultiple UICollection View on single UIView Scrolling is not working while cell data loading from API
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I've been working on a project of using two UICollectionView
's I have on that is the MainViewController with full screen cells that scroll horizontally and one that sits on that full screen cell and scrolls vertically. I have a functionality that adds as well as deletes cells. When a user taps and one of the pages of the MainViewController is deleted using the code below the memory that grew as cells were added is still being retained. Is there something Im doing wrong. All of my delegates are weak references and none of my cells have self referencing closures. Am I doing something wrong thank you for you help
Here is the full project
https://github.com/TheRedCamaro30/Leaky-Nested-UICollectionViews
Add or Remove Cell Delegate
func addCell()
self.mainCollectionView.performBatchUpdates(
guard let last = arr.last else
return
arr.append(last + 1)
let lastIndex = IndexPath(item: last, section: 0)
self.mainCollectionView.insertItems(at: [lastIndex])
) (completed) in
print("Batch updates completed, performed successfully: (completed)")
func removeCell()
self.mainCollectionView.performBatchUpdates(
arr.popLast()
self.mainCollectionView.deleteItems(at: [IndexPath(item: arr.count - 1, section: 0)])
) (competed) in
print("Perform batch updates completed")
Full Sized Cell Cell Population
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: FullPageCell.reuseIdentifier, for: indexPath) as? FullPageCell else
assertionFailure("Fatal Error FullPageCell not dequed")
return UICollectionViewCell()
cell.backgroundColor = UIColor.green
cell.cellTappedDelegate = self
return cell
func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath)
if let cell = cell as? FullPageCell
cell.setUpCollectionView()
SubCollectionView sitting on Full Page Cell Population
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: SmallCell.reuseIdentifier, for: indexPath) as? SmallCell else
assertionFailure("Fatal Error FullPageCell not dequed")
return UICollectionViewCell()
cell.backgroundColor = UIColor.yellow
cell.imageView.image = self.image
return cell
SetUpCollectionView
func setUpCollectionView()
let view = self.contentView
let layout = UICollectionViewFlowLayout()
layout.minimumLineSpacing = 1
layout.minimumInteritemSpacing = 1
layout.scrollDirection = .vertical
layout.itemSize = CGSize(width: (view.bounds.width - 2)/3, height: (view.bounds.width - 2)/3)
collectionView = UICollectionView(frame:view.bounds, collectionViewLayout: layout)
collectionView.dataSource = self
collectionView.delegate = self
collectionView.register(SmallCell.self, forCellWithReuseIdentifier: SmallCell.reuseIdentifier)
collectionView.backgroundColor = UIColor.white
self.collectionView.isPagingEnabled = true
view.addSubview(collectionView)
collectionView.translatesAutoresizingMaskIntoConstraints = false
collectionView.topAnchor.constraint(equalTo: view.topAnchor, constant: 0).isActive = true
collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 0).isActive = true
collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: 0).isActive = true
collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: 0).isActive = true
ios memory-leaks automatic-ref-counting collectionview retain-cycle
|
show 2 more comments
I've been working on a project of using two UICollectionView
's I have on that is the MainViewController with full screen cells that scroll horizontally and one that sits on that full screen cell and scrolls vertically. I have a functionality that adds as well as deletes cells. When a user taps and one of the pages of the MainViewController is deleted using the code below the memory that grew as cells were added is still being retained. Is there something Im doing wrong. All of my delegates are weak references and none of my cells have self referencing closures. Am I doing something wrong thank you for you help
Here is the full project
https://github.com/TheRedCamaro30/Leaky-Nested-UICollectionViews
Add or Remove Cell Delegate
func addCell()
self.mainCollectionView.performBatchUpdates(
guard let last = arr.last else
return
arr.append(last + 1)
let lastIndex = IndexPath(item: last, section: 0)
self.mainCollectionView.insertItems(at: [lastIndex])
) (completed) in
print("Batch updates completed, performed successfully: (completed)")
func removeCell()
self.mainCollectionView.performBatchUpdates(
arr.popLast()
self.mainCollectionView.deleteItems(at: [IndexPath(item: arr.count - 1, section: 0)])
) (competed) in
print("Perform batch updates completed")
Full Sized Cell Cell Population
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: FullPageCell.reuseIdentifier, for: indexPath) as? FullPageCell else
assertionFailure("Fatal Error FullPageCell not dequed")
return UICollectionViewCell()
cell.backgroundColor = UIColor.green
cell.cellTappedDelegate = self
return cell
func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath)
if let cell = cell as? FullPageCell
cell.setUpCollectionView()
SubCollectionView sitting on Full Page Cell Population
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: SmallCell.reuseIdentifier, for: indexPath) as? SmallCell else
assertionFailure("Fatal Error FullPageCell not dequed")
return UICollectionViewCell()
cell.backgroundColor = UIColor.yellow
cell.imageView.image = self.image
return cell
SetUpCollectionView
func setUpCollectionView()
let view = self.contentView
let layout = UICollectionViewFlowLayout()
layout.minimumLineSpacing = 1
layout.minimumInteritemSpacing = 1
layout.scrollDirection = .vertical
layout.itemSize = CGSize(width: (view.bounds.width - 2)/3, height: (view.bounds.width - 2)/3)
collectionView = UICollectionView(frame:view.bounds, collectionViewLayout: layout)
collectionView.dataSource = self
collectionView.delegate = self
collectionView.register(SmallCell.self, forCellWithReuseIdentifier: SmallCell.reuseIdentifier)
collectionView.backgroundColor = UIColor.white
self.collectionView.isPagingEnabled = true
view.addSubview(collectionView)
collectionView.translatesAutoresizingMaskIntoConstraints = false
collectionView.topAnchor.constraint(equalTo: view.topAnchor, constant: 0).isActive = true
collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 0).isActive = true
collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: 0).isActive = true
collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: 0).isActive = true
ios memory-leaks automatic-ref-counting collectionview retain-cycle
Please add code to populate data into collectionview.
– iMHitesh Surani
Mar 26 at 5:35
@iMHiteshSurani please see added code
– TheRedCamaro3.0 3.0
Mar 26 at 13:43
Just comment cell.cellTappedDelegate = self line then Execute code. I think memory issue is due to delegate. You have not manage properly
– iMHitesh Surani
Mar 26 at 18:55
@iMHiteshSurani Thank you for your continued help. The cellTappedDelegate is a weak reference in the collectionViewCell. I use it to detect when a user has tapped a cell in the collectionView inside of the collectionViewCell without it I wouldn't be able to trigger my removeCell function that calls performBatchUpdates.
– TheRedCamaro3.0 3.0
Mar 26 at 19:14
What is setUpCollectionView() method do
– iMHitesh Surani
Mar 27 at 4:08
|
show 2 more comments
I've been working on a project of using two UICollectionView
's I have on that is the MainViewController with full screen cells that scroll horizontally and one that sits on that full screen cell and scrolls vertically. I have a functionality that adds as well as deletes cells. When a user taps and one of the pages of the MainViewController is deleted using the code below the memory that grew as cells were added is still being retained. Is there something Im doing wrong. All of my delegates are weak references and none of my cells have self referencing closures. Am I doing something wrong thank you for you help
Here is the full project
https://github.com/TheRedCamaro30/Leaky-Nested-UICollectionViews
Add or Remove Cell Delegate
func addCell()
self.mainCollectionView.performBatchUpdates(
guard let last = arr.last else
return
arr.append(last + 1)
let lastIndex = IndexPath(item: last, section: 0)
self.mainCollectionView.insertItems(at: [lastIndex])
) (completed) in
print("Batch updates completed, performed successfully: (completed)")
func removeCell()
self.mainCollectionView.performBatchUpdates(
arr.popLast()
self.mainCollectionView.deleteItems(at: [IndexPath(item: arr.count - 1, section: 0)])
) (competed) in
print("Perform batch updates completed")
Full Sized Cell Cell Population
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: FullPageCell.reuseIdentifier, for: indexPath) as? FullPageCell else
assertionFailure("Fatal Error FullPageCell not dequed")
return UICollectionViewCell()
cell.backgroundColor = UIColor.green
cell.cellTappedDelegate = self
return cell
func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath)
if let cell = cell as? FullPageCell
cell.setUpCollectionView()
SubCollectionView sitting on Full Page Cell Population
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: SmallCell.reuseIdentifier, for: indexPath) as? SmallCell else
assertionFailure("Fatal Error FullPageCell not dequed")
return UICollectionViewCell()
cell.backgroundColor = UIColor.yellow
cell.imageView.image = self.image
return cell
SetUpCollectionView
func setUpCollectionView()
let view = self.contentView
let layout = UICollectionViewFlowLayout()
layout.minimumLineSpacing = 1
layout.minimumInteritemSpacing = 1
layout.scrollDirection = .vertical
layout.itemSize = CGSize(width: (view.bounds.width - 2)/3, height: (view.bounds.width - 2)/3)
collectionView = UICollectionView(frame:view.bounds, collectionViewLayout: layout)
collectionView.dataSource = self
collectionView.delegate = self
collectionView.register(SmallCell.self, forCellWithReuseIdentifier: SmallCell.reuseIdentifier)
collectionView.backgroundColor = UIColor.white
self.collectionView.isPagingEnabled = true
view.addSubview(collectionView)
collectionView.translatesAutoresizingMaskIntoConstraints = false
collectionView.topAnchor.constraint(equalTo: view.topAnchor, constant: 0).isActive = true
collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 0).isActive = true
collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: 0).isActive = true
collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: 0).isActive = true
ios memory-leaks automatic-ref-counting collectionview retain-cycle
I've been working on a project of using two UICollectionView
's I have on that is the MainViewController with full screen cells that scroll horizontally and one that sits on that full screen cell and scrolls vertically. I have a functionality that adds as well as deletes cells. When a user taps and one of the pages of the MainViewController is deleted using the code below the memory that grew as cells were added is still being retained. Is there something Im doing wrong. All of my delegates are weak references and none of my cells have self referencing closures. Am I doing something wrong thank you for you help
Here is the full project
https://github.com/TheRedCamaro30/Leaky-Nested-UICollectionViews
Add or Remove Cell Delegate
func addCell()
self.mainCollectionView.performBatchUpdates(
guard let last = arr.last else
return
arr.append(last + 1)
let lastIndex = IndexPath(item: last, section: 0)
self.mainCollectionView.insertItems(at: [lastIndex])
) (completed) in
print("Batch updates completed, performed successfully: (completed)")
func removeCell()
self.mainCollectionView.performBatchUpdates(
arr.popLast()
self.mainCollectionView.deleteItems(at: [IndexPath(item: arr.count - 1, section: 0)])
) (competed) in
print("Perform batch updates completed")
Full Sized Cell Cell Population
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: FullPageCell.reuseIdentifier, for: indexPath) as? FullPageCell else
assertionFailure("Fatal Error FullPageCell not dequed")
return UICollectionViewCell()
cell.backgroundColor = UIColor.green
cell.cellTappedDelegate = self
return cell
func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath)
if let cell = cell as? FullPageCell
cell.setUpCollectionView()
SubCollectionView sitting on Full Page Cell Population
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: SmallCell.reuseIdentifier, for: indexPath) as? SmallCell else
assertionFailure("Fatal Error FullPageCell not dequed")
return UICollectionViewCell()
cell.backgroundColor = UIColor.yellow
cell.imageView.image = self.image
return cell
SetUpCollectionView
func setUpCollectionView()
let view = self.contentView
let layout = UICollectionViewFlowLayout()
layout.minimumLineSpacing = 1
layout.minimumInteritemSpacing = 1
layout.scrollDirection = .vertical
layout.itemSize = CGSize(width: (view.bounds.width - 2)/3, height: (view.bounds.width - 2)/3)
collectionView = UICollectionView(frame:view.bounds, collectionViewLayout: layout)
collectionView.dataSource = self
collectionView.delegate = self
collectionView.register(SmallCell.self, forCellWithReuseIdentifier: SmallCell.reuseIdentifier)
collectionView.backgroundColor = UIColor.white
self.collectionView.isPagingEnabled = true
view.addSubview(collectionView)
collectionView.translatesAutoresizingMaskIntoConstraints = false
collectionView.topAnchor.constraint(equalTo: view.topAnchor, constant: 0).isActive = true
collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 0).isActive = true
collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: 0).isActive = true
collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: 0).isActive = true
ios memory-leaks automatic-ref-counting collectionview retain-cycle
ios memory-leaks automatic-ref-counting collectionview retain-cycle
edited Mar 28 at 20:10
TheRedCamaro3.0 3.0
asked Mar 26 at 3:16
TheRedCamaro3.0 3.0TheRedCamaro3.0 3.0
3101 silver badge11 bronze badges
3101 silver badge11 bronze badges
Please add code to populate data into collectionview.
– iMHitesh Surani
Mar 26 at 5:35
@iMHiteshSurani please see added code
– TheRedCamaro3.0 3.0
Mar 26 at 13:43
Just comment cell.cellTappedDelegate = self line then Execute code. I think memory issue is due to delegate. You have not manage properly
– iMHitesh Surani
Mar 26 at 18:55
@iMHiteshSurani Thank you for your continued help. The cellTappedDelegate is a weak reference in the collectionViewCell. I use it to detect when a user has tapped a cell in the collectionView inside of the collectionViewCell without it I wouldn't be able to trigger my removeCell function that calls performBatchUpdates.
– TheRedCamaro3.0 3.0
Mar 26 at 19:14
What is setUpCollectionView() method do
– iMHitesh Surani
Mar 27 at 4:08
|
show 2 more comments
Please add code to populate data into collectionview.
– iMHitesh Surani
Mar 26 at 5:35
@iMHiteshSurani please see added code
– TheRedCamaro3.0 3.0
Mar 26 at 13:43
Just comment cell.cellTappedDelegate = self line then Execute code. I think memory issue is due to delegate. You have not manage properly
– iMHitesh Surani
Mar 26 at 18:55
@iMHiteshSurani Thank you for your continued help. The cellTappedDelegate is a weak reference in the collectionViewCell. I use it to detect when a user has tapped a cell in the collectionView inside of the collectionViewCell without it I wouldn't be able to trigger my removeCell function that calls performBatchUpdates.
– TheRedCamaro3.0 3.0
Mar 26 at 19:14
What is setUpCollectionView() method do
– iMHitesh Surani
Mar 27 at 4:08
Please add code to populate data into collectionview.
– iMHitesh Surani
Mar 26 at 5:35
Please add code to populate data into collectionview.
– iMHitesh Surani
Mar 26 at 5:35
@iMHiteshSurani please see added code
– TheRedCamaro3.0 3.0
Mar 26 at 13:43
@iMHiteshSurani please see added code
– TheRedCamaro3.0 3.0
Mar 26 at 13:43
Just comment cell.cellTappedDelegate = self line then Execute code. I think memory issue is due to delegate. You have not manage properly
– iMHitesh Surani
Mar 26 at 18:55
Just comment cell.cellTappedDelegate = self line then Execute code. I think memory issue is due to delegate. You have not manage properly
– iMHitesh Surani
Mar 26 at 18:55
@iMHiteshSurani Thank you for your continued help. The cellTappedDelegate is a weak reference in the collectionViewCell. I use it to detect when a user has tapped a cell in the collectionView inside of the collectionViewCell without it I wouldn't be able to trigger my removeCell function that calls performBatchUpdates.
– TheRedCamaro3.0 3.0
Mar 26 at 19:14
@iMHiteshSurani Thank you for your continued help. The cellTappedDelegate is a weak reference in the collectionViewCell. I use it to detect when a user has tapped a cell in the collectionView inside of the collectionViewCell without it I wouldn't be able to trigger my removeCell function that calls performBatchUpdates.
– TheRedCamaro3.0 3.0
Mar 26 at 19:14
What is setUpCollectionView() method do
– iMHitesh Surani
Mar 27 at 4:08
What is setUpCollectionView() method do
– iMHitesh Surani
Mar 27 at 4:08
|
show 2 more comments
1 Answer
1
active
oldest
votes
To insert, delete, or move a single section or item, you must follow
these steps:
Update the data in your data source object.
Call the appropriate method of the collection view to insert or delete the section or item.
Just replace removeCell
method with below code.
func removeCell()
self.mainCollectionView.performBatchUpdates(
arr.popLast()
self.mainCollectionView.deleteItems(at: [IndexPath(item: arr.count - 1, section: 0)])
) (competed) in
print("Perform batch updates completed")
//If it is not worked then reload collectionview
//self.mainCollectionView.reloadData()
Please refer below references.
Inserting, Deleting, and Moving Sections and Items
Collection View Programming Guide for iOS
Thank you for your response, I tried making the changes to conform to the recommended practices but Im still noticing the memory is not dropping after a cell has been deleted using batch updates.
– TheRedCamaro3.0 3.0
Mar 26 at 5:08
add a comment |
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%2f55349341%2fmemory-is-not-released-during-perform-batch-updates-in-collectionview%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
To insert, delete, or move a single section or item, you must follow
these steps:
Update the data in your data source object.
Call the appropriate method of the collection view to insert or delete the section or item.
Just replace removeCell
method with below code.
func removeCell()
self.mainCollectionView.performBatchUpdates(
arr.popLast()
self.mainCollectionView.deleteItems(at: [IndexPath(item: arr.count - 1, section: 0)])
) (competed) in
print("Perform batch updates completed")
//If it is not worked then reload collectionview
//self.mainCollectionView.reloadData()
Please refer below references.
Inserting, Deleting, and Moving Sections and Items
Collection View Programming Guide for iOS
Thank you for your response, I tried making the changes to conform to the recommended practices but Im still noticing the memory is not dropping after a cell has been deleted using batch updates.
– TheRedCamaro3.0 3.0
Mar 26 at 5:08
add a comment |
To insert, delete, or move a single section or item, you must follow
these steps:
Update the data in your data source object.
Call the appropriate method of the collection view to insert or delete the section or item.
Just replace removeCell
method with below code.
func removeCell()
self.mainCollectionView.performBatchUpdates(
arr.popLast()
self.mainCollectionView.deleteItems(at: [IndexPath(item: arr.count - 1, section: 0)])
) (competed) in
print("Perform batch updates completed")
//If it is not worked then reload collectionview
//self.mainCollectionView.reloadData()
Please refer below references.
Inserting, Deleting, and Moving Sections and Items
Collection View Programming Guide for iOS
Thank you for your response, I tried making the changes to conform to the recommended practices but Im still noticing the memory is not dropping after a cell has been deleted using batch updates.
– TheRedCamaro3.0 3.0
Mar 26 at 5:08
add a comment |
To insert, delete, or move a single section or item, you must follow
these steps:
Update the data in your data source object.
Call the appropriate method of the collection view to insert or delete the section or item.
Just replace removeCell
method with below code.
func removeCell()
self.mainCollectionView.performBatchUpdates(
arr.popLast()
self.mainCollectionView.deleteItems(at: [IndexPath(item: arr.count - 1, section: 0)])
) (competed) in
print("Perform batch updates completed")
//If it is not worked then reload collectionview
//self.mainCollectionView.reloadData()
Please refer below references.
Inserting, Deleting, and Moving Sections and Items
Collection View Programming Guide for iOS
To insert, delete, or move a single section or item, you must follow
these steps:
Update the data in your data source object.
Call the appropriate method of the collection view to insert or delete the section or item.
Just replace removeCell
method with below code.
func removeCell()
self.mainCollectionView.performBatchUpdates(
arr.popLast()
self.mainCollectionView.deleteItems(at: [IndexPath(item: arr.count - 1, section: 0)])
) (competed) in
print("Perform batch updates completed")
//If it is not worked then reload collectionview
//self.mainCollectionView.reloadData()
Please refer below references.
Inserting, Deleting, and Moving Sections and Items
Collection View Programming Guide for iOS
edited Mar 26 at 4:12
answered Mar 26 at 4:07
iMHitesh SuraniiMHitesh Surani
4,45215 silver badges39 bronze badges
4,45215 silver badges39 bronze badges
Thank you for your response, I tried making the changes to conform to the recommended practices but Im still noticing the memory is not dropping after a cell has been deleted using batch updates.
– TheRedCamaro3.0 3.0
Mar 26 at 5:08
add a comment |
Thank you for your response, I tried making the changes to conform to the recommended practices but Im still noticing the memory is not dropping after a cell has been deleted using batch updates.
– TheRedCamaro3.0 3.0
Mar 26 at 5:08
Thank you for your response, I tried making the changes to conform to the recommended practices but Im still noticing the memory is not dropping after a cell has been deleted using batch updates.
– TheRedCamaro3.0 3.0
Mar 26 at 5:08
Thank you for your response, I tried making the changes to conform to the recommended practices but Im still noticing the memory is not dropping after a cell has been deleted using batch updates.
– TheRedCamaro3.0 3.0
Mar 26 at 5:08
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
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.
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%2f55349341%2fmemory-is-not-released-during-perform-batch-updates-in-collectionview%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
Please add code to populate data into collectionview.
– iMHitesh Surani
Mar 26 at 5:35
@iMHiteshSurani please see added code
– TheRedCamaro3.0 3.0
Mar 26 at 13:43
Just comment cell.cellTappedDelegate = self line then Execute code. I think memory issue is due to delegate. You have not manage properly
– iMHitesh Surani
Mar 26 at 18:55
@iMHiteshSurani Thank you for your continued help. The cellTappedDelegate is a weak reference in the collectionViewCell. I use it to detect when a user has tapped a cell in the collectionView inside of the collectionViewCell without it I wouldn't be able to trigger my removeCell function that calls performBatchUpdates.
– TheRedCamaro3.0 3.0
Mar 26 at 19:14
What is setUpCollectionView() method do
– iMHitesh Surani
Mar 27 at 4:08