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 6363789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:04:51+00:00 2026-05-25T00:04:51+00:00

A standard pattern used in Scala class library is definition of classes within classes

  • 0

A standard pattern used in Scala class library is definition of classes within classes and traits. And most of the operations of objects of parent classes result in objects of those inner classes being created. Each inner class is different for each object.

e.g.
See source for scala.io.Source and LineIterator. I think this is the simplest one in standard library.

As documents suggest below are two different classes.

val s1:Source = ...
val s2:Source = ...
s1.getLines.getClass != s2.getLines.getClass //true if s1 != s2

Meaning two classes are created.

As the whole collection library is using the same pattern, what are the effects on permgen space for long running processes?

  • 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-25T00:04:52+00:00Added an answer on May 25, 2026 at 12:04 am

    I’m not sure how you concluded that if s1 != s2, then s1.getLines.getClass != s2.getLines.getClass. If I create two instances of BufferedSource using Source.fromFile, then both will return an instance of the same class scala.io.BufferedSource$BufferedLineIterator when I call getLines.

    scala> s1 == s2
    res6: Boolean = false
    
    scala> s1.getLines.getClass == s2.getLines.getClass
    res7: Boolean = true
    

    It’s true that Scala creates a lot of classes, but this is done at compile-time, not runtime, so perm gen should not be more of a issue for long-running processes.

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

Sidebar

Related Questions

Case classes in Scala are standard classes enhanced with pattern-matching, equals, ... (or am
There's a standard pattern for events in .NET - they use a delegate type
What's the point in the standard pattern for event delegates in .net? I.e. the
I am having a very hard time finding a standard pattern / best practice
I have a pretty standard Repository pattern going, where repositories are injected into my
I am using a standard repository pattern with a service layer which calls the
So standard Agile philosophy would recommend making your domain classes simple POCOs which are
So I'm using this pretty standard jquery plugin pattern whereby you can grab an
I'm looking for a JavaScript implementation of the memento pattern (GoF) to be used
I have used gmail countless times and was wondering if there are standard patterns

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.