Skip to content

Fix all test memory leaks and related issues in ssc and tcs#749

Merged
sjanzou merged 54 commits into
patchfrom
ssc_719
Feb 11, 2022
Merged

Fix all test memory leaks and related issues in ssc and tcs#749
sjanzou merged 54 commits into
patchfrom
ssc_719

Conversation

@sjanzou

@sjanzou sjanzou commented Feb 7, 2022

Copy link
Copy Markdown
Collaborator

No description provided.

sjanzou and others added 30 commits January 10, 2022 01:57
memory leak fixed for first two pvwattsv8 tests but remains if all pvwattsv8 tests are run
rewrite create_weatherdata_array and free_weatherdata_array
rewrite create_winddata_array and free_winddata_array
…on, fix memory leak in sscapi_test, json_to_ssc_data
…etest causes memory leaks on windows when failures reported
… leaks on Windows 10

CMPvsamv1BatteryIntegration_cmod_pvsamv1.LCOS_test_cashloan"; // pass with many memory leaks  windows 10
CMPvsamv1BatteryIntegration_cmod_pvsamv1.ResidentialDCBatteryModelPriceSignalDispatch"; // pass with many memory leaks  windows 10
@sjanzou

sjanzou commented Feb 7, 2022

Copy link
Copy Markdown
Collaborator Author

No memory leaks on macOs 12.0.1 and all tests passing on Github Actions and Windows.
We can discuss running new tests added in Windows debug mode to prevent future leaks.
The Windows (and mac) SEH should no longer occur.

Questions and comments and updated practices are welcomed!

@sjanzou sjanzou linked an issue Feb 7, 2022 that may be closed by this pull request
@sjanzou

sjanzou commented Feb 7, 2022

Copy link
Copy Markdown
Collaborator Author

The jc-community contributor seems to occur from a different computer I was testing and updating on... interesting how they came into existence...

@sjanzou

sjanzou commented Feb 7, 2022

Copy link
Copy Markdown
Collaborator Author

There are 6 failing tests only on macOS 12.0.1 with the Apple Silicon chip with maybe too tight of tolerance:

[ RUN ] voltage_table_lib_battery_voltage_test.calculateMaxChargeHourly1
/Users/imacuser/Public/Projects/GitHub/NREL/ssc/test/shared_test/lib_battery_voltage_test.cpp:674: Failure
The difference between cap->SOC() and 99.99 is 0.010000000000005116, which exceeds 1e-2, where
cap->SOC() evaluates to 100,
99.99 evaluates to 99.989999999999995, and
1e-2 evaluates to 0.01.
[ FAILED ] voltage_table_lib_battery_voltage_test.calculateMaxChargeHourly1 (0 ms)
[ RUN ] voltage_table_lib_battery_voltage_test.calculateMaxChargeHourly2
/Users/imacuser/Public/Projects/GitHub/NREL/ssc/test/shared_test/lib_battery_voltage_test.cpp:705: Failure
The difference between max_current_calc and -0.998 is 0.0019999999999997797, which exceeds 1e-3, where
max_current_calc evaluates to -0.99999999999999978,
-0.998 evaluates to -0.998, and
1e-3 evaluates to 0.001.
/Users/imacuser/Public/Projects/GitHub/NREL/ssc/test/shared_test/lib_battery_voltage_test.cpp:709: Failure
The difference between cap->SOC() and 99.984 is 0.016000000000005343, which exceeds 1e-3, where
cap->SOC() evaluates to 100,
99.984 evaluates to 99.983999999999995, and
1e-3 evaluates to 0.001.
[ FAILED ] voltage_table_lib_battery_voltage_test.calculateMaxChargeHourly2 (0 ms)
[ RUN ] voltage_table_lib_battery_voltage_test.calculateMaxChargeHourly3
/Users/imacuser/Public/Projects/GitHub/NREL/ssc/test/shared_test/lib_battery_voltage_test.cpp:756: Failure
The difference between cap->SOC() and 99.99 is 0.010000000000005116, which exceeds 1e-2, where
cap->SOC() evaluates to 100,
99.99 evaluates to 99.989999999999995, and
1e-2 evaluates to 0.01.
/Users/imacuser/Public/Projects/GitHub/NREL/ssc/test/shared_test/lib_battery_voltage_test.cpp:757: Failure
The difference between cap->I() * model->battery_voltage() and -4615 is 1.4800619834704776, which exceeds 1, where
cap->I() * model->battery_voltage() evaluates to -4616.4800619834705,
-4615 evaluates to -4615, and
1 evaluates to 1.
[ FAILED ] voltage_table_lib_battery_voltage_test.calculateMaxChargeHourly3 (0 ms)
[ RUN ] voltage_table_lib_battery_voltage_test.calculateMaxChargeSubHourly1
/Users/imacuser/Public/Projects/GitHub/NREL/ssc/test/shared_test/lib_battery_voltage_test.cpp:786: Failure
The difference between cap->SOC() and 99.99 is 0.010000000000005116, which exceeds 1e-2, where
cap->SOC() evaluates to 100,
99.99 evaluates to 99.989999999999995, and
1e-2 evaluates to 0.01.
/Users/imacuser/Public/Projects/GitHub/NREL/ssc/test/shared_test/lib_battery_voltage_test.cpp:787: Failure
The difference between cap->I() * model->battery_voltage() and -5128 is 1.4222910927455814, which exceeds 1, where
cap->I() * model->battery_voltage() evaluates to -5129.4222910927456,
-5128 evaluates to -5128, and
1 evaluates to 1.
[ FAILED ] voltage_table_lib_battery_voltage_test.calculateMaxChargeSubHourly1 (0 ms)
[ RUN ] voltage_table_lib_battery_voltage_test.calculateMaxChargeSubHourly2
/Users/imacuser/Public/Projects/GitHub/NREL/ssc/test/shared_test/lib_battery_voltage_test.cpp:820: Failure
The difference between cap->SOC() and 99.99 is 0.010000000000005116, which exceeds 1e-2, where
cap->SOC() evaluates to 100,
99.99 evaluates to 99.989999999999995, and
1e-2 evaluates to 0.01.
[ FAILED ] voltage_table_lib_battery_voltage_test.calculateMaxChargeSubHourly2 (0 ms)

@brtietz

brtietz commented Feb 7, 2022

Copy link
Copy Markdown
Collaborator

Ignore my previous comment - I was running the tests on patch and failed to check out this branch.

@brtietz

brtietz commented Feb 7, 2022

Copy link
Copy Markdown
Collaborator

No SEH exceptions in one run on Windows (much better than usual!)

The test results make it look like increasing the tolerance is a reasonable option. It looks like most could be increased by 10%, while those currently set to a value of "1" should perhaps be "2".

@Matthew-Boyd Matthew-Boyd left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The fixed memory leaks and other changes in the CSP files look great, thank you very much for doing this! I guess we'll have to make good lasting impressions now.

@sjanzou

sjanzou commented Feb 10, 2022

Copy link
Copy Markdown
Collaborator Author

No SEH exceptions in one run on Windows (much better than usual!)

The test results make it look like increasing the tolerance is a reasonable option. It looks like most could be increased by 10%, while those currently set to a value of "1" should perhaps be "2".

Updated in commit 63b343e with noted tolerance update in detailed commit message.

I would like to merge sooner than later so I do not need to keep updating tests that are modified on the patch branch without these changes ;-)

@tyneises tyneises removed their request for review February 10, 2022 15:23

@cpaulgilman cpaulgilman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

FYI -- these changes to not seem to affect simulation run times, test results generated in Windows 10, Intel Core i5-6400 2.7GHz CPU 4 Cores, 32 GB RAM, no SSD hard drive:

sim-time-test.zip

@dguittet dguittet left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Great job!

@brtietz brtietz mentioned this pull request Feb 10, 2022
@sjanzou sjanzou merged commit e839883 into patch Feb 11, 2022
@sjanzou

sjanzou commented Feb 11, 2022

Copy link
Copy Markdown
Collaborator Author

FYI -- these changes to not seem to affect simulation run times, test results generated in Windows 10, Intel Core i5-6400 2.7GHz CPU 4 Cores, 32 GB RAM, no SSD hard drive:

sim-time-test.zip

@cpaulgilman, the column titles in the spreadsheet have 'release' and 'patch'... is the 'release' the patch branch of ssc and the 'patch' branch the ssc_719 branch of ssc (this branch)?

I am not sure why ETES Single Owner is now taking 63s longer....

@sjanzou

sjanzou commented Feb 11, 2022

Copy link
Copy Markdown
Collaborator Author

Great job!

Thank you and thank you for the quick review!

@sjanzou sjanzou deleted the ssc_719 branch February 11, 2022 10:13
@cpaulgilman

Copy link
Copy Markdown
Collaborator

FYI -- these changes to not seem to affect simulation run times, test results generated in Windows 10, Intel Core i5-6400 2.7GHz CPU 4 Cores, 32 GB RAM, no SSD hard drive:
sim-time-test.zip

@cpaulgilman, the column titles in the spreadsheet have 'release' and 'patch'... is the 'release' the patch branch of ssc and the 'patch' branch the ssc_719 branch of ssc (this branch)?

I am not sure why ETES Single Owner is now taking 63s longer....

Yes, patch = ssc_719 and release = SAM 2021.12.02.

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.

Memory leaks in ssc/Tests

5 participants