Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AssetLibrary Asset never removed from _assetDictionary #162

Closed
Jeff94 opened this issue Oct 24, 2011 · 5 comments
Closed

AssetLibrary Asset never removed from _assetDictionary #162

Jeff94 opened this issue Oct 24, 2011 · 5 comments
Assignees
Labels

Comments

@Jeff94
Copy link

Jeff94 commented Oct 24, 2011

Hi all, while I was working on some memory leaks, I find this :

private function removeAssetFromDict(asset : IAsset) : void {

if (_assetDictDirty) rehashAssetDict();

if (_assetDictionary.hasOwnProperty(asset.assetNamespace)) {

        if (_assetDictionary.hasOwnProperty(asset.name))
        // ------> Should be if ( assetDictionary[asset.assetNamespace].hasOwnProperty(asset.name) )

                   delete _assetDictionary[asset.assetNamespace][asset.name];
                   }
        }

Cheers, Jeff

@richardolsson
Copy link
Member

I wasn't sure what you meant, but having looked at the actual code I can see what you are saying. Will fix this.

Note to self: The "Might be" line in the bug report is not currently in the actual removeAssetFromDict() method. This line needs to be amended in AssetLibrary.as:469.

@ghost ghost assigned richardolsson Oct 25, 2011
@Jeff94
Copy link
Author

Jeff94 commented Oct 25, 2011

Sorry my explananation was not so clear, so inside removeAssetFromDict method ( AssetLibrary )

the line :

if (_assetDictionary.hasOwnProperty(asset.name))

Should be :

if ( assetDictionary[asset.assetNamespace].hasOwnProperty(asset.name) )

Because we are dealing with assetDictionary[asset.assetNamespace][asset.name]

Hope this help ;-)

@richardolsson
Copy link
Member

Yeah, like I said I understood what you meant once I looked in the code. :) Thanks.

@redefy
Copy link

redefy commented May 9, 2012

As soon as this bug will be fixed? Because at the moment we have no possibility to remove the asset from the library.

To get rid of it, it is enough to correct only two lines:
for each (asset in _assets) { //not correct
for each (asset in old_assets) { // correct
and
if (_assetDictionary.hasOwnProperty(asset.name)) //not correct
if (_assetDictionary [asset.assetNamespace] .hasOwnProperty (asset.name)) // correct

@richardolsson
Copy link
Member

While fixing this, I also implemented some measure to better manage memory when removing assets in the shape of properly deleting namespaces from the internal dictionary when the namespace is empty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants