Giter Club home page Giter Club logo

Comments (5)

keijiro avatar keijiro commented on May 29, 2024

Will I have any garbage collection issues?

Yes. Other internal objects (_stream, _decoder, _texture, _updater) will be leaked.

I'd recommend destroying the HapPlayer component and recreate a new instance to open another file.

from klakhap.

keijiro avatar keijiro commented on May 29, 2024

I'm closing this issue now. Please feel free to reopen it for further problems.

from klakhap.

jBachalo avatar jBachalo commented on May 29, 2024

Thanks. Just thinking this would be a very useful feature.
And could I simply do the following?

`public void Open(string filePath, PathMode pathMode = PathMode.StreamingAssets)
    {
        if (_demuxer != null)
        {
            Debug.LogError("Stream has already been opened.");
            //_stream, _decoder, _texture, _updater

            _stream.Dispose();
            _stream = null;

             _decoder.Dispose();
            _decoder = null;

            UnityEngine.Object.Destroy( _texture );
            _texture = null;

             _updater.Dispose();
            _updater = null;


            _demuxer.Dispose();// new line
        _demuxer = null; // new line
            //return;
        }

        _filePath = filePath;
        _pathMode = pathMode;

        OpenInternal();
    }`

from klakhap.

keijiro avatar keijiro commented on May 29, 2024

I think your modification is on the right track this time. Yes, it might be a useful feature, it needs extensive testing though.

from klakhap.

jBachalo avatar jBachalo commented on May 29, 2024

Thanks. Unfortunately even with above still memory leak(s)! Based on your suggestion am creating 2nd component on same GameObject as HapPlayer.
Testing and will post results.

     `using System.Collections;
     using System.Collections.Generic;
     using UnityEngine;
    using UnityEngine.Playables;

    namespace Klak.Hap{

public class DestroyHAP : MonoBehaviour
{
    HapPlayer _hap;
    public RenderTexture rt;

 public void DestroyComponent()
  {
    if(GetComponent<HapPlayer>() != null){
    Destroy(GetComponent<HapPlayer>());
            }
  }

public HapPlayer CreateComponent()
{
   _hap = gameObject.AddComponent<HapPlayer>();
        _hap.targetTexture= rt;
        _hap.targetRenderer= GetComponent<MeshRenderer>();
        return _hap;
    
}
}

}`

from klakhap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.