Skip to content

Conversation

@axtox
Copy link

@axtox axtox commented Nov 29, 2025

Description

There's a minor optimization in HighResTimer where we can avoid allocating a new EventArgs object every time the timer elapses. Instead, we can use EventArgs.Empty to reduce memory usage and improve performance, which is especially important in resource-constrained environments.

Motivation and Context

  • There is related Discord thread on the HighResTimer issue that is crashing due to out of memory exception and one of the causes is unnecessary memory allocation during the event firing.

How Has This Been Tested?

  • Only successfully rebuild the solution without flashing to the ESP32

Types of changes

  • Improvement (non-breaking change that improves a feature, code or algorithm)
  • Bug fix (non-breaking change which fixes an issue with code or algorithm)
  • New feature (non-breaking change which adds functionality to code)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Config and build (change in the configuration and build system, has no impact on code or features)
  • Dependencies (update dependencies and changes associated, has no impact on code or features)
  • Unit Tests (add new Unit Test(s) or improved existing one(s), has no impact on code or features)
  • Documentation (changes or updates in the documentation, has no impact on code or features)

Checklist:

  • My code follows the code style of this project (only if there are changes in source code).
  • My changes require an update to the documentation (there are changes that require the docs website to be updated).
  • I have updated the documentation accordingly (the changes require an update on the docs in this repo).
  • I have read the CONTRIBUTING document.
  • I have tested everything locally and all new and existing tests passed (only if there are changes in source code).
  • I have added new tests to cover my changes.

There's a minor optimization in HighResTimer where
we can avoid allocating a new EventArgs object every
time the timer elapses. Instead, we can use EventArgs.Empty
to reduce memory usage and improve performance which
is especially important in resource-constrained environments.

Signed-off-by: Anton Kulikov <[email protected]>
@nfbot nfbot added the Type: bug Something isn't working label Nov 29, 2025
@coderabbitai
Copy link

coderabbitai bot commented Nov 29, 2025

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • nanoFramework.Hardware.Esp32/HighResTimer.cs is excluded by none and included by none

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@nfbot nfbot added the Type: enhancement New feature or request label Nov 29, 2025
@CLAassistant
Copy link

CLAassistant commented Nov 29, 2025

CLA assistant check
All committers have signed the CLA.

@axtox
Copy link
Author

axtox commented Nov 29, 2025

@dotnet-policy-service agree

@josesimoes josesimoes changed the title Fix unnecessary EventArgs allocation in HighResTimer Fix unnecessary EventArgs allocation in HighResTimer Dec 2, 2025
@josesimoes
Copy link
Member

\azp run

Copy link
Member

@josesimoes josesimoes left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you for the improvement.

@josesimoes josesimoes removed the Type: bug Something isn't working label Dec 2, 2025
@josesimoes josesimoes changed the title Fix unnecessary EventArgs allocation in HighResTimer Remove unnecessary EventArgs allocation in HighResTimer Dec 2, 2025
@josesimoes josesimoes enabled auto-merge (squash) December 2, 2025 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants