开发者

Jruby persistence problem

开发者 https://www.devze.com 2023-02-19 03:14 出处:网络
I want to store objects in jruby for a short time. The objects use procs so I seem to have trouble storing it into db. If anyone has good ideas for how to persist jruby objects for 1-5 mins it would b

I want to store objects in jruby for a short time. The objects use procs so I seem to have trouble storing it into db. If anyone has good ideas for how to persist jruby objects for 1-5 mins it would be great.

These objects are quite large, specifically, celerity browser objects.

For now, I have created a model in jruby like so:

class Persist
    @@persistHash ||= Hash.new

    def self.storeItem(id, item)
        @@persistHash[id.to_s] = item
    end

    def self.getItem(id)
       开发者_运维知识库 return @@persistHash[id.to_s]
    end
end

I have warbled the app and deployed it to glassfish v2.

I run the program and it works fine for a while. But after a day, if I call 'get' right after 'store' (10-20 secs) I am returned nil.

I can't find any errors in logs.

EDIT: I have also found that the item is indeed inserted into the hashtable (the hashtable did not run out of memory during insert):

Before 24 hrs:

Persist.storeItem() followed by Persist.getItem() works fine.

A http call for store. Then another http call for get returns the object.

After 24 hrs:

Persist.storeItem() followed by Persist.getItem() works fine.

A http call for store. Then another http call for get returns nil.


I don't see the object being deleted at any point.

I would examine the JVM using other tools. It could very well be that you've exhausted memory but the log message / exception never gets created to report the memory exhaustion.

May I suggest hooking up JMX monitoring of the various heap regions and create a means by which the hash can purged of old objects.

Wish I had more for you. Good luck!

0

精彩评论

暂无评论...
验证码 换一张
取 消