Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6649383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:46:03+00:00 2026-05-26T00:46:03+00:00

I’m doing IPC between Java and some C code by just creating an external

  • 0

I’m doing IPC between Java and some C code by just creating an external C process that takes some commandline arguments and writes its results to standard out. This is inside a server application, so the data returned needs to be fed directly back into the OutputStream of an HttpServletResponse, which I’m currently doing with a simple Apache commons IOUtils.copy(inputStream, outputStream). The current solution is convenient in that the external process can generate arbitrarily large responses without consuming arbitrary amounts of memory. Unfortunately, the cost of spawning the external process, as well as all the setup the actual process logic requires, is making the overhead unacceptable for small jobs. So I’d like to switch to JNI, which will get rid of the external process overhead and allow much of the setup of these tasks to be performed statically once at server startup time.

But I’m now wondering how to preserve the current streaming nature of the responses- I’d rather not simply make the JNI call return a byte array or even a ByteBuffer, because I’d like to keep memory usage capped and low. So, what techniques are available to call C logic and return essentially arbitrarily large byte arrays in a way that will let me get them into an OutputStream without consuming arbitrarily large amounts of memory, and without much overhead for setting up the C environment.

FWIW, this C code is basically running a passed in Lua script on a pile of records, and returning the output for each record.

The main one coming to mind is to just pass the OutputStream into the native method, and call write on it intermittently using JNI reflection as the C code generates its response. Are there better alternatives I’m missing? Files? Zeromq?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:46:04+00:00Added an answer on May 26, 2026 at 12:46 am

    You could have your JNI method return an InputStream with a read callback into JNI, but I think passing the OutputStream into the JNI as you suggest is a cleaner solution.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from
I am trying to understand how to use SyndicationItem to display feed which is
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.