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;








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










share|improve this question
























  • 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

















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










share|improve this question
























  • 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













0












0








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










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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

















  • 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












1 Answer
1






active

oldest

votes


















0















To insert, delete, or move a single section or item, you must follow
these steps:



  1. Update the data in your data source object.


  2. 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






share|improve this answer

























  • 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










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
);



);













draft saved

draft discarded


















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









0















To insert, delete, or move a single section or item, you must follow
these steps:



  1. Update the data in your data source object.


  2. 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






share|improve this answer

























  • 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















0















To insert, delete, or move a single section or item, you must follow
these steps:



  1. Update the data in your data source object.


  2. 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






share|improve this answer

























  • 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













0












0








0








To insert, delete, or move a single section or item, you must follow
these steps:



  1. Update the data in your data source object.


  2. 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






share|improve this answer
















To insert, delete, or move a single section or item, you must follow
these steps:



  1. Update the data in your data source object.


  2. 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







share|improve this answer














share|improve this answer



share|improve this answer








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

















  • 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








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.



















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현