Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #24362 > unrolled thread

Memory & Pixel Usage Etc: As Number of JTable Rows & Columns Increases

Started byHaircuts Are Important <clusardi2k@aol.com>
First post2013-06-11 12:42 -0700
Last post2013-06-14 10:42 -0700
Articles 13 — 7 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  Memory & Pixel Usage Etc: As Number of JTable Rows & Columns Increases Haircuts Are Important <clusardi2k@aol.com> - 2013-06-11 12:42 -0700
    Re: Memory & Pixel Usage Etc: As Number of JTable Rows & Columns Increases Knute Johnson <nospam@knutejohnson.com> - 2013-06-11 15:56 -0700
      Re: Memory & Pixel Usage Etc: As Number of JTable Rows & Columns Increases "John B. Matthews" <nospam@nospam.invalid> - 2013-06-11 22:51 -0400
      Re: Memory & Pixel Usage Etc: As Number of JTable Rows & Columns Increases clusardi2k@aol.com - 2013-06-11 23:29 -0700
      Re: Memory & Pixel Usage Etc: As Number of JTable Rows & Columns Increases clusardi2k@aol.com - 2013-06-11 23:35 -0700
        Re: Memory & Pixel Usage Etc: As Number of JTable Rows & Columns Increases Haircuts Are Important <clusardi2k@aol.com> - 2013-06-12 05:11 -0700
          Re: Memory & Pixel Usage Etc: As Number of JTable Rows & Columns Increases Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-06-12 09:12 -0700
        Re: Memory & Pixel Usage Etc: As Number of JTable Rows & Columns Increases Knute Johnson <nospam@knutejohnson.com> - 2013-06-12 08:21 -0700
          Re: Memory & Pixel Usage Etc: As Number of JTable Rows & Columns Increases Haircuts Are Important <clusardi2k@aol.com> - 2013-06-12 09:13 -0700
            Re: Memory & Pixel Usage Etc: As Number of JTable Rows & Columns Increases Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-06-12 13:29 -0400
              Re: Memory & Pixel Usage Etc: As Number of JTable Rows & Columns Increases Haircuts Are Important <clusardi2k@aol.com> - 2013-06-14 05:47 -0700
                Re: Memory & Pixel Usage Etc: As Number of JTable Rows & Columns Increases Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-06-14 10:37 -0400
                  Re: Memory & Pixel Usage Etc: As Number of JTable Rows & Columns Increases Lew <lewbloch@gmail.com> - 2013-06-14 10:42 -0700

#24362 — Memory & Pixel Usage Etc: As Number of JTable Rows & Columns Increases

FromHaircuts Are Important <clusardi2k@aol.com>
Date2013-06-11 12:42 -0700
SubjectMemory & Pixel Usage Etc: As Number of JTable Rows & Columns Increases
Message-ID<9f2c5c11-c4e1-42bc-8c82-e0255ea897a5@m8g2000yqf.googlegroups.com>
How much memory does a JTable use as the number of rows and columns in
increases.

How can I measure memory useage and number of pixels used by a JTable.

Thank you,

[toc] | [next] | [standalone]


#24368

FromKnute Johnson <nospam@knutejohnson.com>
Date2013-06-11 15:56 -0700
Message-ID<kp89mi$uk$1@dont-email.me>
In reply to#24362
On 6/11/2013 12:42 PM, Haircuts Are Important wrote:
> How much memory does a JTable use as the number of rows and columns in
> increases.
>
> How can I measure memory useage and number of pixels used by a JTable.
>
> Thank you,
>

As to memory I have no idea but I am curious why it matters.  Most 
modern computers have a boat load of memory and virtual memory.  As for 
pixels, you can create it, display it on a JPanel, pack it and ask it 
how big it is.

-- 

Knute Johnson

[toc] | [prev] | [next] | [standalone]


#24371

From"John B. Matthews" <nospam@nospam.invalid>
Date2013-06-11 22:51 -0400
Message-ID<nospam-766B6E.22514011062013@news.aioe.org>
In reply to#24368
In article <kp89mi$uk$1@dont-email.me>,
 Knute Johnson <nospam@knutejohnson.com> wrote:

> On 6/11/2013 12:42 PM, Haircuts Are Important wrote:
> > How much memory does a JTable use as the number of rows and 
> > columns increases.
> >
> > How can I measure memory useage and number of pixels used by 
> > a JTable.
> 
> As to memory I have no idea but I am curious why it matters.  
> Most modern computers have a boat load of memory and virtual 
> memory.  As for pixels, you can create it, display it on a 
> JPanel, pack it and ask it how big it is.

Knute's right: Because JTable uses the flyweight pattern to render 
cells, it's memory footprint scales with the number of visible 
cells. The rest depends on the data structure that underlies your 
TablelModel. Profile to be sure.

You've asked about this before, in a now deleted question:

<https://groups.google.com/forum/?fromgroups&hl=en#!topic/comp.lang.java.programmer/CjA3KBqjvVs>

-- 
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>

[toc] | [prev] | [next] | [standalone]


#24372

Fromclusardi2k@aol.com
Date2013-06-11 23:29 -0700
Message-ID<769a4ec4-c714-4cba-aa68-0864070beb3f@googlegroups.com>
In reply to#24368
On Tuesday, June 11, 2013 6:56:49 PM UTC-4, Knute Johnson wrote:
> On 6/11/2013 12:42 PM, Haircuts Are Important wrote: > How much 
> memory does a JTable use as the number of rows and columns in > 
> increases. > > How can I measure memory useage and number of pixels 
> used by a JTable. > > Thank you, > As to memory I have no idea but 
> I am curious why it matters. Most modern computers have a boat load 
> of memory and virtual memory. As for pixels, you can create it, 
> display it on a JPanel, pack it and ask it how big it is. -- Knute Johnson

[toc] | [prev] | [next] | [standalone]


#24373

Fromclusardi2k@aol.com
Date2013-06-11 23:35 -0700
Message-ID<572d9ee8-aa0c-4275-a41c-e9bebccfbc21@googlegroups.com>
In reply to#24368
On Tuesday, June 11, 2013 6:56:49 PM UTC-4, Knute Johnson wrote:
> On 6/11/2013 12:42 PM, Haircuts Are Important wrote: > How much 
> memory does a JTable use as the number of rows and columns in > 
> increases. > > How can I measure memory useage and number of pixels 
> used by a JTable. > > Thank you, > As to memory I have no idea but 
> I am curious why it matters. Most modern computers have a boat load 
> of memory and virtual memory. As for pixels, you can create it, 
> display it on a JPanel, pack it and ask it how big it is. -- Knute 
> Johnson

It matters to me because of overall efficiency questions. Basically, if I have many other programs running or computationally intense prgrams running at the same time will my new java project slow all these programs down if it has many rows and columns. Can I improve the effiency more by restricting my new project to only a few rows and columns.

Thanks,

[toc] | [prev] | [next] | [standalone]


#24378

FromHaircuts Are Important <clusardi2k@aol.com>
Date2013-06-12 05:11 -0700
Message-ID<72c9496b-124a-4b41-8953-5b188280b09e@9g2000yqq.googlegroups.com>
In reply to#24373
On Jun 12, 2:35 am, clusard...@aol.com wrote:
> On Tuesday, June 11, 2013 6:56:49 PM UTC-4, Knute Johnson wrote:
> > On 6/11/2013 12:42 PM, Haircuts Are Important wrote: > How much
> > memory does a JTable use as the number of rows and columns in >
> > increases. > > How can I measure memory useage and number of pixels
> > used by a JTable. > > Thank you, > As to memory I have no idea but
> > I am curious why it matters. Most modern computers have a boat load
> > of memory and virtual memory. As for pixels, you can create it,
> > display it on a JPanel, pack it and ask it how big it is. -- Knute
> > Johnson
>
> It matters to me because of overall efficiency questions. Basically, if I have many other programs running or computationally intense prgrams running at the same time will my new java project slow all these programs down if it has many rows and columns. Can I improve the effiency more by restricting my new project to only a few rows and columns.
>
> Thanks,

Does java have something like the old "sizeof" function in the
language C.

[toc] | [prev] | [next] | [standalone]


#24382

FromDaniel Pitts <newsgroup.nospam@virtualinfinity.net>
Date2013-06-12 09:12 -0700
Message-ID<k51ut.52980$cw4.9418@newsfe21.iad>
In reply to#24378
On 6/12/13 5:11 AM, Haircuts Are Important wrote:
> On Jun 12, 2:35 am, clusard...@aol.com wrote:
>> On Tuesday, June 11, 2013 6:56:49 PM UTC-4, Knute Johnson wrote:
>>> On 6/11/2013 12:42 PM, Haircuts Are Important wrote: > How much
>>> memory does a JTable use as the number of rows and columns in >
>>> increases. > > How can I measure memory useage and number of pixels
>>> used by a JTable. > > Thank you, > As to memory I have no idea but
>>> I am curious why it matters. Most modern computers have a boat load
>>> of memory and virtual memory. As for pixels, you can create it,
>>> display it on a JPanel, pack it and ask it how big it is. -- Knute
>>> Johnson
>>
>> It matters to me because of overall efficiency questions. Basically, if I have many other programs running or computationally intense prgrams running at the same time will my new java project slow all these programs down if it has many rows and columns. Can I improve the effiency more by restricting my new project to only a few rows and columns.
>>
>> Thanks,
>
> Does java have something like the old "sizeof" function in the
> language C.
No.

The JTable itself won't add a lot of extra memory usage, most of the 
usage will likely come from your data itself.

Even if you had sizeof, the best way to determine the actual efficiency 
of a program is by testing and profiling.

If you're thinking on the scale of a few hundred, I wouldn't even worry 
about it.  tens of thousands I'd start to get a little concerned, but 
I'd test first.

No easy answer, you just gotta fill your data structure and see what 
happens.

[toc] | [prev] | [next] | [standalone]


#24381

FromKnute Johnson <nospam@knutejohnson.com>
Date2013-06-12 08:21 -0700
Message-ID<kpa3dh$5jo$1@dont-email.me>
In reply to#24373
On 6/11/2013 11:35 PM, clusardi2k@aol.com wrote:
> On Tuesday, June 11, 2013 6:56:49 PM UTC-4, Knute Johnson wrote:
>> On 6/11/2013 12:42 PM, Haircuts Are Important wrote: > How much
>> memory does a JTable use as the number of rows and columns in >
>> increases. > > How can I measure memory useage and number of
>> pixels used by a JTable. > > Thank you, > As to memory I have no
>> idea but I am curious why it matters. Most modern computers have a
>> boat load of memory and virtual memory. As for pixels, you can
>> create it, display it on a JPanel, pack it and ask it how big it
>> is. -- Knute Johnson
>
> It matters to me because of overall efficiency questions. Basically,
> if I have many other programs running or computationally intense
> prgrams running at the same time will my new java project slow all
> these programs down if it has many rows and columns. Can I improve
> the effiency more by restricting my new project to only a few rows
> and columns.
>
> Thanks,
>

It's not an answerable question.  Speed is relative to the amount of 
memory, processor and video card resources available divided by the load.

How many elements does your JTable have?

--

Knute Johnson

[toc] | [prev] | [next] | [standalone]


#24383

FromHaircuts Are Important <clusardi2k@aol.com>
Date2013-06-12 09:13 -0700
Message-ID<a9e35bca-b530-49a0-94c4-fc920069e120@n13g2000yqj.googlegroups.com>
In reply to#24381
On Jun 12, 11:21 am, Knute Johnson <nos...@knutejohnson.com> wrote:
> On 6/11/2013 11:35 PM, clusard...@aol.com wrote:
> > On Tuesday, June 11, 2013 6:56:49 PM UTC-4, Knute Johnson wrote:
> >> On 6/11/2013 12:42 PM, Haircuts Are Important wrote: > How much
> >> memory does a JTable use as the number of rows and columns in >
> >> increases. > > How can I measure memory useage and number of
> >> pixels used by a JTable. > > Thank you, > As to memory I have no
> >> idea but I am curious why it matters. Most modern computers have a
> >> boat load of memory and virtual memory. As for pixels, you can
> >> create it, display it on a JPanel, pack it and ask it how big it
> >> is. -- Knute Johnson
>
> > It matters to me because of overall efficiency questions. Basically,
> > if I have many other programs running or computationally intense
> > prgrams running at the same time will my new java project slow all
> > these programs down if it has many rows and columns. Can I improve
> > the effiency more by restricting my new project to only a few rows
> > and columns.
>
> > Thanks,
>
> It's not an answerable question.  Speed is relative to the amount of
> memory, processor and video card resources available divided by the load.
>
> How many elements does your JTable have?
>

The main JTable has only m rows and n columns with each cell
consisting of alphanumeric data of 10 characters or less.

[toc] | [prev] | [next] | [standalone]


#24388

FromEric Sosman <esosman@comcast-dot-net.invalid>
Date2013-06-12 13:29 -0400
Message-ID<kpaash$j0h$1@dont-email.me>
In reply to#24383
On 6/12/2013 12:13 PM, Haircuts Are Important wrote:
> On Jun 12, 11:21 am, Knute Johnson <nos...@knutejohnson.com> wrote:
>>[...]
>> How many elements does your JTable have?
>>
>
> The main JTable has only m rows and n columns with each cell
> consisting of alphanumeric data of 10 characters or less.

     Set m=0 or n=0 (or both), and your memory problems will be over.
Wasn't that simple?

-- 
Eric Sosman
esosman@comcast-dot-net.invalid

[toc] | [prev] | [next] | [standalone]


#24403

FromHaircuts Are Important <clusardi2k@aol.com>
Date2013-06-14 05:47 -0700
Message-ID<429cccb8-27fb-4544-b560-461770aafb2c@v2g2000yqa.googlegroups.com>
In reply to#24388
Disregarding garbage collection, what do you think about "ever" using
freeMemory() as an approximation for memory useage:

    Runtime.getRuntime().gc();
    long before = Runtime.getRuntime().freeMemory();
    long after = Runtime.getRuntime().freeMemory();

Thanks,

[toc] | [prev] | [next] | [standalone]


#24405

FromEric Sosman <esosman@comcast-dot-net.invalid>
Date2013-06-14 10:37 -0400
Message-ID<kpf9i0$p3l$1@dont-email.me>
In reply to#24403
On 6/14/2013 8:47 AM, Haircuts Are Important wrote:
> Disregarding garbage collection, what do you think about "ever" using
> freeMemory() as an approximation for memory useage:
>
>      Runtime.getRuntime().gc();
>      long before = Runtime.getRuntime().freeMemory();
>      long after = Runtime.getRuntime().freeMemory();

     "Disregarding garbage collection," freeMemory() is a reliable
way to measure a meaningless quantity.  Disregarding gravity, how
high can you jump?

     It's possible to use totalMemory() and freeMemory() and a lot
of care (calling gc() "suggests" garbage collection and promises
only a "best effort") to estimate the sizes of simple objects like
Integers, fixed-length Strings or arrays, and so on.  But with more
complex objects containing references to other complex objects it
becomes much more difficult.  You seem to be concerned about how
much memory a JTable uses -- well, does that include the TableModel?
The data in the TableModel?  The TableColumnModel, the internal
HashTables that store editors and renderers, the editors and
renderers themselves, ...?  You've got a fairly thorny definitional
problem before you can even get started.

     Ah, the heck with it.  Here's the output of a micro-benchmark
I wrote some time ago, estimating the size of a `new JTable()' by
fitting least-squares lines relating "instance count" to "heap used:"

	500 instances: 5247.664 bytes each
	1000 instances: 5248.128 bytes each
	1500 instances: 5220.9584 bytes each
	2000 instances: 5220.9328 bytes each
	2500 instances: 5224.7922285714285 bytes each
	3000 instances: 5228.693142857142 bytes each
	3500 instances: 5231.899428571429 bytes each
	4000 instances: 5234.469066666667 bytes each
	4500 instances: 5236.533624242425 bytes each
	5000 instances: 5238.165672727273 bytes each
	BUILD SUCCESSFUL (total time: 14 seconds)

There you have it -- but *what* do you have?

-- 
Eric Sosman
esosman@comcast-dot-net.invalid

[toc] | [prev] | [next] | [standalone]


#24407

FromLew <lewbloch@gmail.com>
Date2013-06-14 10:42 -0700
Message-ID<56efddbe-d2ff-45a0-a7ca-578c04e612f3@googlegroups.com>
In reply to#24405
Eric Sosman wrote:
> Haircuts Are Important wrote:
>> Disregarding garbage collection, what do you think about "ever" using
>> freeMemory() as an approximation for memory useage:
> 
> >      Runtime.getRuntime().gc();

Ha.

>>      long before = Runtime.getRuntime().freeMemory();

Long before what?

>>      long after = Runtime.getRuntime().freeMemory();

Long after what?

>      "Disregarding garbage collection," freeMemory() is a reliable
> way to measure a meaningless quantity.  Disregarding gravity, how
> high can you jump?
> 
>      It's possible to use totalMemory() and freeMemory() and a lot
> of care (calling gc() "suggests" garbage collection and promises
> only a "best effort") to estimate the sizes of simple objects like
> Integers, fixed-length Strings or arrays, and so on.  But with more
> complex objects containing references to other complex objects it
> becomes much more difficult.  You seem to be concerned about how
> much memory a JTable uses -- well, does that include the TableModel?
> The data in the TableModel?  The TableColumnModel, the internal
> HashTables that store editors and renderers, the editors and
> renderers themselves, ...?  You've got a fairly thorny definitional
> problem before you can even get started.
> 
>      Ah, the heck with it.  Here's the output of a micro-benchmark
> I wrote some time ago, estimating the size of a `new JTable()' by
> fitting least-squares lines relating "instance count" to "heap used:"
> 
> 	500 instances: 5247.664 bytes each
> 	1000 instances: 5248.128 bytes each
> 	1500 instances: 5220.9584 bytes each
> 	2000 instances: 5220.9328 bytes each
> 	2500 instances: 5224.7922285714285 bytes each
> 	3000 instances: 5228.693142857142 bytes each
> 	3500 instances: 5231.899428571429 bytes each
> 	4000 instances: 5234.469066666667 bytes each
> 	4500 instances: 5236.533624242425 bytes each
> 	5000 instances: 5238.165672727273 bytes each
> 	BUILD SUCCESSFUL (total time: 14 seconds)
> 
> There you have it -- but *what* do you have?

A meaningless benchmark of a meaningless quantity that lacks predictive value.

As you point out. Complicated by the fact that the same structure in a program 
can occupy not just somewhat different amounts of memory, as you show, but 
wildly different amounts. Optimization can remove an object from heap altogether
under certain circumstances, circumstances that can change during program execution
and cause that same structure to occupy heap at other times.

That is over 100% reduction in size, depending on which of the "in-heap" memory 
numbers you use as 100%.

And "Haircuts", for God's sake stop deleting your posts. What in the heck is wrong with you?

-- 
Lew

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web