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

  • SEARCH
  • Home
  • 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 7169419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:59:09+00:00 2026-05-28T14:59:09+00:00

In one of my Controllers, I have multiple URLs that will ultimately render in

  • 0

In one of my Controllers, I have multiple URLs that will ultimately render in the same way. For example, this method scans the network on which the server resides, caches a String representation of each connected device and each device listening on a specific port, and then sends that information to another method to render:

public static void networkScan(String networkTarget, String port)
{
    //These two lists will never have more than 256 total entries
    List<InetSocketAddress> listeningDevices;
    Map<String, String> allDevices;

    ...Logic for discovering network devices...

    //Store the results in a cache, for history preservation in the browser
    Cache.set(session.getId() + "listeningDevices", listeningDevices);
    Cache.set(session.getId() + "allDevices", allDevices);
    showScan(listeningDevices, allDevices);
}

public static void showScan(List<InetSocketAddress> listeningDevices, Map<String, String> allDevices)
{
    render(listeningDevices, allDevices);
}

public static void getCachedScan()
{
    List<InetSocketAddress> listeningDevices = (List<InetSocketAddress>)Cache.get(session.getId() + "listeningDevices");
    Map<String, String> allDevices = (Map<String, String>)Cache.get(session.getId() + "allDevices");
    if(listeningDevices == null)
        listeningDevices = new ArrayList<InetSocketAddress>();
    if(allDevices == null)
        allDevices = new TreeMap<String, String>();

    renderScan(listeningDevices, allDevices);
}

Doing it this way results in Play doing some weird array copying that ends up taking infinite memory. If I were to change my call of showScan() to simply render() and create a view with the name networkScan.html, it all works just fine, no memory bugs.

I have several other methods that also use showScan, based on different caching settings. I don’t want lots of views that are all essentially copies of each other, so I’m trying to go through just one method with one corresponding view.

  • 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-28T14:59:09+00:00Added an answer on May 28, 2026 at 2:59 pm

    Turns out that calling an action method creates a redirect event, which resulted in all sorts of copying objects into URLs. I still don’t understand how that mushroomed into using over a gigabyte of memory for a collection of Strings that rarely numbered above 100, and never above 256, but I found a way of avoiding the redirect event.

    As I was directed to do in an answer on Google Groups, I made use of the @Util interceptor on the showScan method:

    @Util
    public static void showScan(List<InetSocketAddress> listeningDevices, Map<String, String> allDevices)
    {
        renderTemplate("Admin/showScan.html", listeningDevices, allDevices);
    }
    

    Marking a method with @Util unfortunately makes it use the template of the calling method, but the call to renderTemplate() allows me to use a single template that I specify.

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

Sidebar

Related Questions

I have created a new method in one of the project's controllers that it
I have a table view project with multiple controllers and another one that is
I have a controller method that returns a jSON object and in one calling
I have multiple SimpleFormController controllers. One controller contains a command object used to filter
I have a UITabbar with multiple view controllers. One of them is a UITableView.
Is there a way to have a singleton resource used by multiple controllers? We
I have multiple controllers one in Areas /Areas/Demo/Admin/AdminController and other in main site /Controller/Admin/AdminController
I have an action in one of my controllers which creates a downloadable zip
i have a controller like this one : <?php if( ! defined('BASEPATH')) exit ('No
there is a situation where a have multiple controllers like a town_center controller, a

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.