RobotOS.jl icon indicating copy to clipboard operation
RobotOS.jl copied to clipboard

Memory leak

Open mistermult opened this issue 5 years ago • 1 comments

Hello,

thank you for the great library. The following program does nothing, yet the memory consumption is increasing monotonically (560MB RSS, 1.2GB VM-Size after some time):

using RobotOS
@rosimport geometry_msgs.msg: Point, Pose2D
rostypegen()
using .geometry_msgs.msg

function main()
    init_node("juliatest")
    #pub = Publisher{Point}("jlpoint", queue_size=10)
    loop_rate = Rate(200.0)
    #npt = Point(0, 0, 0)
    while ! is_shutdown()
        #npt.x = npt.x + 1
        #npt.y = npt.y + 1
        #publish(pub, npt)
        rossleep(loop_rate)
    end
end

main()

The program in Python (it even does more) has not an increasing memory consumption and uses less memory (50MB RSS, 380MB VM-Size). Moreover, it uses only 1% instead of 4% of CPU.

#!/usr/bin/env python
# license removed for brevity
import rospy
from std_msgs.msg import String
from geometry_msgs.msg import Point

def main():
    rospy.init_node('python_test')
    pub = rospy.Publisher('pypoint', Point, queue_size=10)
    pt = Point(0, 0, 0)
    rate = rospy.Rate(200)
    while not rospy.is_shutdown():
        pub.publish(pt)
        rate.sleep()

if __name__ == '__main__':
    try:
        main()
    except rospy.ROSInterruptException:
        pass

What do you think is the reason for the increasing memory consumption? Can you give some hint? Maybe I can fix it. Do you know why the CPU consumption is higher?

mistermult avatar Mar 06 '20 06:03 mistermult

Hi @mistermult, have you investigated this further by chance?

jdlangs avatar Jun 05 '20 18:06 jdlangs