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

Hypnosis is a memory hog #586

Open
davepl opened this issue Jan 8, 2024 · 11 comments
Open

Hypnosis is a memory hog #586

davepl opened this issue Jan 8, 2024 · 11 comments

Comments

@davepl
Copy link
Contributor

davepl commented Jan 8, 2024

The Hypnosis effect has a static declaration of two bytes per pixel that go into base RAM. These should be dynamically allocated using PreferPSRAM or similar. The only catch is the [x][y] addressing in the Draw() code gets harder, but I think we need to reclaim the memory.

@davepl
Copy link
Contributor Author

davepl commented Jan 8, 2024

BTW, if the allocation actually happens after setup() is called, this will already be in PSRAM for Mesmerizer, so no win - but if it's allocated before setup() - like as a global - then it will use base ram.

@robertlipe
Copy link
Contributor

robertlipe commented Jan 8, 2024 via email

@davepl
Copy link
Contributor Author

davepl commented Jan 8, 2024 via email

@davepl
Copy link
Contributor Author

davepl commented Jan 8, 2024 via email

@davepl
Copy link
Contributor Author

davepl commented Jan 8, 2024 via email

@robertlipe
Copy link
Contributor

robertlipe commented Jan 8, 2024 via email

@davepl
Copy link
Contributor Author

davepl commented Jan 8, 2024 via email

@rbergen
Copy link
Collaborator

rbergen commented Jan 9, 2024

But I’m not fully cromulent on all the construction paths and their timing. If they’re loaded dynamically by effects manager, and are NOT instantiated in the table, then it’d be OK.

Effects are constructed during the execution of setup(), but pretty much towards the end of its invocation. Also, effects are explicitly allocated using psram_allocator.
The table that's put together in effects.cpp only contains the effect factories; this means that in practice the table is a couple of small lambdas for each effect in the list.

Any mallocs over, I think, 16 bytes already goes into psram.

It's actually anything over 128 bytes. But considering the previous that shouldn't matter anyway.

Construct() and Destruct() could be called on Start() and End(), could they not?

The challenge with the destruct part is that we have no "End()". An effect is told to prepare itself for drawing through Start(), and then told to draw frames through Draw(). It is not told when its time in the spotlight has ended.

@robertlipe
Copy link
Contributor

robertlipe commented Jan 9, 2024 via email

@davepl
Copy link
Contributor Author

davepl commented Jan 9, 2024 via email

@robertlipe
Copy link
Contributor

robertlipe commented Jan 9, 2024 via email

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

No branches or pull requests

3 participants