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

Update ExecutionEnvironment to cache command line #680

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

snorrsi
Copy link

@snorrsi snorrsi commented Apr 19, 2024

Simple fix for unnecessary GC Allocation using command line

See #428

Copy link

google-cla bot commented Apr 19, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

/// <summary>
/// Cached lower case CommandLine
/// </summary>
private static string Cached_Environment_CommandLine_Lower = null;
Copy link

@Tommigun1980 Tommigun1980 Oct 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a constant so name should not use underscore notation.

/// <summary>
/// Whether the editor was started in batch mode.
/// </summary>
public static bool InBatchMode {
get { return Environment.CommandLine.ToLower().Contains("-batchmode"); }
get { return Environment_CommandLine_Lower.Contains("-batchmode"); }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is better than before but couldn't you just read all three of the switches it's interested in inside a constructor and just return booleans in the properties? This still runs unnecessary string operations every frame.

@Tommigun1980
Copy link

This has to be merged in. Is the jar resolver maintained anymore or has Google sunset Unity support? The editor is constantly allocating memory which makes long-running automated test running inside editor slow down over time etc. Of course you can't read the command line every frame, read it once like this pull request does. Merge it in now please.

Tommigun1980
Tommigun1980 approved these changes Oct 1, 2024
@Tommigun1980
Copy link

@paulinon @a-maurice Could you just approve this as it is not ok that the resolver constantly allocates memory every frame.

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

Successfully merging this pull request may close these issues.

3 participants