scorpiontahir02
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2016
05:20 AM
Why is using "Eval" bad in production?
Wandering around these forums I have found various posts regarding use of Eval being bad. But the only issues with its use, mentioned, that I could find were
So I was thinking, if there is a method "RunMyApp()" that handles all the application execution workflow, and application's "Main()" is like
And I change the "Main()" to
Do the both points mentioned earlier about using Eval being the bad practice still hold? As ideally if there is no error in the call to "RunMyApp()"
Although I will call eval again if the "RunMyApp()" encountered some error but that will be rare, so, memory leaks or compilation times still not be an issue. Basically what I want to do is keep my application running even if there is some one time error.
Also, are there any other issues other than the mentioned two?
- It compiles the code, so is slow.
- When called multiple times, it leaks memory.
So I was thinking, if there is a method "RunMyApp()" that handles all the application execution workflow, and application's "Main()" is like
function Main()
RunMyApp()
end function
And I change the "Main()" to
function Main()
eval("RunMyApp()")
end function
Do the both points mentioned earlier about using Eval being the bad practice still hold? As ideally if there is no error in the call to "RunMyApp()"
- The code will only be compiled once.
- Eval will be called once so no memory leaks.
Although I will call eval again if the "RunMyApp()" encountered some error but that will be rare, so, memory leaks or compilation times still not be an issue. Basically what I want to do is keep my application running even if there is some one time error.
Also, are there any other issues other than the mentioned two?
6 REPLIES 6

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2016
02:06 PM
Re: Why is using "Eval" bad in production?
"scorpiontahir02" wrote:
2. Eval will be called once so no memory leaks.
I don't know for sure, and I'm sure EnTerr will correct me on this ;), but it was always my assumption that anything run inside of Eval would bypass garbage collection, resulting in leaks. If that is indeed the case, then it doesn't matter if you call Eval once or a 100 times, you're going to end up leaking pretty much everything in your code.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
scorpiontahir02
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2016
01:51 AM
Re: Why is using "Eval" bad in production?
"TheEndless" wrote:
I don't know for sure, and I'm sure EnTerr will correct me on this ;), but it was always my assumption that anything run inside of Eval would bypass garbage collection, resulting in leaks. If that is indeed the case, then it doesn't matter if you call Eval once or a 100 times, you're going to end up leaking pretty much everything in your code.
Any way to test the memory leaks? r2d2_bitmaps only displays graphics memory information and doesn't seem to be an issue there even after running the app for more than 15 hours now.
Available memory 38279104 used 720896 max 39000000

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2016
12:16 PM
Re: Why is using "Eval" bad in production?
"scorpiontahir02" wrote:
Any way to test the memory leaks? r2d2_bitmaps only displays graphics memory information and doesn't seem to be an issue there even after running the app for more than 15 hours now.
"free" might give you more insight into the memory usage.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)

squirreltown
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2016
05:14 PM
Re: Why is using "Eval" bad in production?
"TheEndless" wrote:
"free" might give you more insight into the memory usage.
Which "bucket" of memory is this measuring?, the space where the code runs? My 4200 lists 379312 as total mem., so It's definitely not graphic memory.
Kinetics Screensavers
scorpiontahir02
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2016
07:48 AM
Re: Why is using "Eval" bad in production?
"TheEndless" wrote:
"free" might give you more insight into the memory usage.
Thank you very much, I will experiment with this and will post how much eval affects the memory.
On a side note, can you please give me reference/list/link to these commands? I knew only about r2d2_bitmaps. I could not found these in the docs, but these can be really helpful in development.

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2016
10:31 AM
Re: Why is using "Eval" bad in production?
"scorpiontahir02" wrote:
On a side note, can you please give me reference/list/link to these commands? I knew only about r2d2_bitmaps. I could not found these in the docs, but these can be really helpful in development.
There is no publicly documented list that I'm aware of. They've just come up on this forum over the years. Aside from genkey and I think, but don't recall specifics, some ancient form of an ECP sendkeys commands, r2d2_bitmaps and free are the only ones that have been mentioned and/or documented.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)