100,000 different script method, program memory is very larg

Discussion about the open-source Phalanger [?] project.

100,000 different script method, program memory is very larg

Postby tao » October 31st, 2015, 1:13 am

100,000 different script method, program process memory is very large, can add unload temp assembly public method?? , have a better solution?????

Thank you very much.

Assembly beisen_AppFramework_TempFile_0CF8D27731D05A79C556E0E242E4E4D8~8#35863539#08d2e17a0584efaf, Version 1.0.0.0
Assembly beisen_AppFramework_TempFile_000B2394F04EC39A533F92CC2F63FFD0~8#35863539#08d2e11ae09dcbd0, Version 1.0.0.0
..........

http://dfiles.tita.com/portal/110006/19 ... 02408d.jpg
http://dfiles.tita.com/portal/110006/8c ... ed893d.jpg
http://dfiles.tita.com/portal/110006/b5 ... bf8cd6.jpg
http://dfiles.tita.com/portal/110006/0c ... b73656.jpg
http://dfiles.tita.com/portal/110006/1e ... cbc34c.jpg
http://dfiles.tita.com/portal/110006/76 ... 8cb4aa.jpg

Image

Image

Image

Image

Image

Image



my c# code:

Code: Select all
private static ScriptContext _scriptContext;

  static PhpDynamicScript()
    {
        _scriptFileHashDict = new Dictionary<string, string>();
        _scriptContext = new ScriptContext(ApplicationContext.Default);
        _scriptContext.GlobalVariables["_logger"] =
           _scriptContext.NewObject(@"Beisen\Logging\LogWrapper"); ;
        Tools.CreateDirectory(DynamicScriptEngineSettings.Instance.ScriptTempFile);
    }



  private bool ExecuteDynamicScript(string code, out string errorMsg)
    {
        code = "<? " + code + " ?>";
        errorMsg = string.Empty;
        try
        {
            string scriptHash = Tools.GetScriptHash(code);
            string scriptFileFullName =      Path.Combine(DynamicScriptEngineSettings.Instance.ScriptTempFile, scriptHash);
            string scriptFile = GenerateScriptFile(scriptFileFullName, code);
            _scriptContext.Include(scriptFile, true);
            _compiled = true;
            return true;
        }
        catch (Exception ex)
        {
            _logger.Error(new CompileErrorException("compile error",ex));
            errorMsg = "compile error";
            return false;
        }
    }

   public T CallFunction<T>(string functionName, params object[] parameters)
    {
        ArgumentHelper.AssertNotEmpty(functionName, "functionName");
        if (_scriptContext != null)
        {
            var result = InternalCallFunction(functionName, parameters);
            if (result == null)
                return default(T);
            if (result is ClrObject)
            {
                var clrObject = ((ClrObject) result);
                dynamic realObj = (T)clrObject.RealObject;
                if (clrObject.RuntimeFields != null)
                    foreach (var field in clrObject.RuntimeFields)
                        realObj[field.Key.String] = field.Value;
                return realObj;
            }
            return (T)result;
        }
        return default(T);
    }


  private object InternalCallFunction(string functionName, params object[] parameters)
    {
        if (!_scriptContext.DeclaredFunctions.ContainsKey(functionName))
        {
            _logger.Error(
                new ScriptFunctionNotFoundException(String.Format("TenantId:{0},FunctionName:{1},Language:{2}",
                    _tenantId, functionName, Language)));
            return null;
        }
        var result = _scriptContext.Call(functionName, parameters);
        if (result != null && result.Value != null)
            return result.Value;
        return null;
    }


Thank you very much....
tao
 
Posts: 1
Joined: October 31st, 2015, 1:10 am

Return to Phalanger project

Who is online

Users browsing this forum: No registered users and 31 guests

cron

User Control Panel

Login

Who is online

In total there are 31 users online :: 0 registered, 0 hidden and 31 guests (based on users active over the past 5 minutes)
Most users ever online was 227 on March 28th, 2024, 9:13 am

Users browsing this forum: No registered users and 31 guests