Studio project creation outofmemoryexception - usage of memory in AutomaticTasks such as Analyze or Convert

Dear community,

I am batch creating Studio projects via a command line tool and noticed that at some point, e.g. when creating hundreds of (small) projects, I get an outofmemoryexception, I assume directly from the 32bit CLR (when memory usage has almost reached the allowed 1.8 GB). As a quick workaround, I have put the actual project creation into a separate command line application which I now trigger from the main app. Since the separate cmd is killed after project creation, I thereby enforce memory release. However, this experience makes me think that Automatic Tasks such as Convert and Analyze are maybe not releasing enough unused memory for the GC to collect and the memory usage should be profiled again?

Anybody else reached this limit?

Best wishes,
Simon

Parents
  • Can you share your code, or at least the part with tasks?

    Romulus Crisan | Translation Productivity Development Manager | SDL | (twitter) @cromica_82 | (blog) http://www.romuluscrisan.com/

  • The following will give the outofmemoryexception:

     

    TranslationProviderServer TMServer = GetTMServer(serverURL, username, password);
    System.Collections.ObjectModel.ReadOnlyCollection<ServerBasedTranslationMemory> list = GetTMList(serverURL, username, password);

    TMServer = null;
    System.GC.Collect();

    List<Uri> TMs = new List<Uri>();
    Uri TM_path;

    foreach (var TM in list)
    {
    if (TM.Name.IndexOf(TM_name) != -1) // I only loop through TMs with specific part of TM name
    {
    srcLocale = TM.LanguageDirections[0].SourceLanguageCode;
    trgLocale = TM.LanguageDirections[0].TargetLanguageCode;
    TM_path = TM.Uri;

    #region "newProject"
    ProjectTemplateReference projTemplate = new ProjectTemplateReference(projTemplatePath);
    FileBasedProject newProject = new FileBasedProject(this.GetProjectInfo(srcLocale, trgLocale), projTemplate);
    #endregion

    #region "Save"
    newProject.Save();
    #endregion

    #region "CallAddFiles"
    this.AddFiles(newProject, docFolder, recursion);
    #endregion

    #region "CallConvert"
    this.ConvertFiles(newProject);
    #endregion

    #region "CallGetAnalyzeSettings"
    this.GetAnalyzeSettings(
    newProject,
    trgLocale,
    reportCrossFileRepetitions,
    reportInternalFuzzyMatchLeverage);
    #endregion

    TranslationProviderConfiguration config = newProject.GetTranslationProviderConfiguration();
    TranslationProviderReference refer = new TranslationProviderReference(TM_path);
    TranslationProviderCascadeEntry entry = new TranslationProviderCascadeEntry(refer, false, true, false);

    while (config.Entries.Count != 0) // just in case there are TM Providers, remove them
    {
    config.Entries.RemoveAt(0);
    }
    config.Entries.Add(entry);
    newProject.UpdateTranslationProviderConfiguration(config);
    newProject.Save();

    #region "CallRunFileAnalysis"
    this.RunFileAnalysis(newProject, trgLocale, serverURL, username, password);
    newProject.Save();
    #endregion

    #region "GenerateReports"
    this.CreateReports(newProject, docFolder, procmode, srcLocale, trgLocale);
    #endregion

    newProject.Delete();

    newProject = null;
    projTemplate = null;
    config = null;
    refer = null;
    entry = null;
    System.GC.Collect();
    }
    }

Reply
  • The following will give the outofmemoryexception:

     

    TranslationProviderServer TMServer = GetTMServer(serverURL, username, password);
    System.Collections.ObjectModel.ReadOnlyCollection<ServerBasedTranslationMemory> list = GetTMList(serverURL, username, password);

    TMServer = null;
    System.GC.Collect();

    List<Uri> TMs = new List<Uri>();
    Uri TM_path;

    foreach (var TM in list)
    {
    if (TM.Name.IndexOf(TM_name) != -1) // I only loop through TMs with specific part of TM name
    {
    srcLocale = TM.LanguageDirections[0].SourceLanguageCode;
    trgLocale = TM.LanguageDirections[0].TargetLanguageCode;
    TM_path = TM.Uri;

    #region "newProject"
    ProjectTemplateReference projTemplate = new ProjectTemplateReference(projTemplatePath);
    FileBasedProject newProject = new FileBasedProject(this.GetProjectInfo(srcLocale, trgLocale), projTemplate);
    #endregion

    #region "Save"
    newProject.Save();
    #endregion

    #region "CallAddFiles"
    this.AddFiles(newProject, docFolder, recursion);
    #endregion

    #region "CallConvert"
    this.ConvertFiles(newProject);
    #endregion

    #region "CallGetAnalyzeSettings"
    this.GetAnalyzeSettings(
    newProject,
    trgLocale,
    reportCrossFileRepetitions,
    reportInternalFuzzyMatchLeverage);
    #endregion

    TranslationProviderConfiguration config = newProject.GetTranslationProviderConfiguration();
    TranslationProviderReference refer = new TranslationProviderReference(TM_path);
    TranslationProviderCascadeEntry entry = new TranslationProviderCascadeEntry(refer, false, true, false);

    while (config.Entries.Count != 0) // just in case there are TM Providers, remove them
    {
    config.Entries.RemoveAt(0);
    }
    config.Entries.Add(entry);
    newProject.UpdateTranslationProviderConfiguration(config);
    newProject.Save();

    #region "CallRunFileAnalysis"
    this.RunFileAnalysis(newProject, trgLocale, serverURL, username, password);
    newProject.Save();
    #endregion

    #region "GenerateReports"
    this.CreateReports(newProject, docFolder, procmode, srcLocale, trgLocale);
    #endregion

    newProject.Delete();

    newProject = null;
    projTemplate = null;
    config = null;
    refer = null;
    entry = null;
    System.GC.Collect();
    }
    }

Children