Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have written a program which records protocol messages between an application

ID: 653140 • Letter: I

Question

I have written a program which records protocol messages between an application and a hardware device which matches each application request with each hardware response. This is so that I can later remove the hardware, connect a 'replay' application to the main application and wait for an application request and reply with a matched copy of the requisite hardware reply message.

My replay application saves the matched request/response in a list (using C++ std::list).

This works fine on a small interaction session. My problem now is that I need to be able to use the replay over a long long session. With my current implementation, the replay program eventually uses up all available memory on my computer and crashes.

So I need some sort of lookahead - and not parse the whole session in one go.

Can anyone make any suggestions on how to get started?

Explanation / Answer

(Just re-iterating so that you know that I know what you are saying)
It sounds like you are effectively creating an in-memory structure of the various requests and responses. With a large session, this is creating a significantly large structure that is then taking more memory than you have available.

Instead of trying to keep the entire thing in memory, would it be feasible to go to a disk based system? For example one could go to a Berkeley db on disk. It has C and C++ bindings that you could use to tie into your current application.

With this approach, one could hash the request (last I recall, Berkeley db likes to have simple keys) and store/retrieve based on the hash. This way, one doesn't keep the entire database (or list) in memory, but rather does fast indexed lookups on disk.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote