-
Notifications
You must be signed in to change notification settings - Fork 435
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Summary
The gcinfo()
function in luau returns only the integer part of memory usage in KB, stripping the fractional bytes portion that is present in standard lua implementations.
Steps to Reproduce
echo "print(gcinfo())" > test.luau && luau test.luau # Output: 36
Expected Behavior
Based on standard lua behavior of collectgarbage('count')
, gcinfo()
should return the memory usage in KB as a floating-point number, including fractional bytes. This value multiplied by 1024 gives the exact number of bytes in use.
For comparison:
- Lua 5.1:
26.814453125
- Lua 5.2:
21.8193359375
- Lua 5.3:
22.8564453125
- Lua 5.4:
20.8408203125
Actual Behavior
Luau returns only the integer part: 36
Test Commands Used
# Standard Lua versions for comparison
lua51 -e "print(collectgarbage('count'))" # Output: 26.814453125
lua52 -e "print(collectgarbage('count'))" # Output: 21.8193359375
lua53 -e "print(collectgarbage('count'))" # Output: 22.8564453125
lua54 -e "print(collectgarbage('count'))" # Output: 20.8408203125
# Luau behavior
echo "print(gcinfo())" > test.luau && luau test.luau # Output: 36
Impact
This bug affects:
- Code portability between Lua and Luau
- Memory profiling accuracy
- Applications that rely on precise memory usage measurements
Additional Context
The gcinfo()
function is documented as returning "the total heap size in kilobytes", without mentioning that it should be truncated to an integer.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working