Files and Memory Usage

Discussion in 'Java' started by TNguyen, Dec 8, 2006.

  1. TNguyen

    TNguyen Guest

    >From the perspective of a utility like top, would having a file open
    and continuously write to it without closing it increase the memory
    usage?
    TNguyen, Dec 8, 2006
    #1
    1. Advertising

  2. TNguyen wrote:
    > >From the perspective of a utility like top, would having a file open

    > and continuously write to it without closing it increase the memory
    > usage?


    Note: When I go to reply to your message, my software
    inserts a character before your text to indicate that I
    am 'quoting' your words, ..see the '>' above?

    The stray '>' at the beginning of your *original* message
    makes it appear that *you* were also quoting someone else!

    Please leave off the initial '>' in future, to help
    save the confusion.

    ( And no, I have no idea what 'top' is, nor its behaviour
    with Java I/O streams. Yoo might clarify what it is, with
    a link. )

    Andrew T.
    Andrew Thompson, Dec 9, 2006
    #2
    1. Advertising

  3. Andrew Thompson wrote:
    ...
    > ( And no, I have no idea what 'top' is, nor its behaviour
    > with Java I/O streams. Yoo might clarify what it is, with
    > a link. )


    I do not think I said that very clear, so a second attempt..

    I suggest you post a link to the 'top' tool that you
    are using, so others (who may not know what it is)
    can find out about it, and be able to better answer your
    question.

    Andrew T.
    Andrew Thompson, Dec 9, 2006
    #3
  4. TNguyen

    sgoo Guest

    Well, I believe he is talking about the very very basic *nix tool --
    /usr/bin/top.

    I don't know the answer to the question, but it should be very easy to
    write a program to test it.
    sgoo, Dec 9, 2006
    #4
  5. TNguyen

    Mark Rafn Guest

    TNguyen <> wrote:
    >From the perspective of a utility like top


    Top is darned handy, but you shouldn't optimize for any given tool.
    Understand what the tool is measuring and decide if it's important to you
    (note: top's VIRT and RES numbers probably should be important to you most of
    the time, but not because they're in top, just because OS memory allocated and
    resident is important).

    >would having a file open and continuously write to it without closing it
    >increase the memory usage?


    Not usually. You can write many gigs to a file without using any more
    memory for the VM. There may be files or filesystems where this is not true
    (some sort of virtual filesystem that lives in the VM, maybe?), but if you're
    seeing memory grow, it's far more likely you're leaking memory (leaking
    object references, usually, through a misplaced or hidden static) when
    reading/generating/writing the data than that the actual write is using
    memory.
    --
    Mark Rafn <http://www.dagon.net/>
    Mark Rafn, Dec 9, 2006
    #5
  6. TNguyen

    Lars Enderin Guest

    Andrew Thompson skrev:
    > TNguyen wrote:
    >> >From the perspective of a utility like top, would having a file open

    >> and continuously write to it without closing it increase the memory
    >> usage?

    >
    > Note: When I go to reply to your message, my software
    > inserts a character before your text to indicate that I
    > am 'quoting' your words, ..see the '>' above?
    >
    > The stray '>' at the beginning of your *original* message
    > makes it appear that *you* were also quoting someone else!
    >

    Many mail and news agents will put a > in front of From if it starts a
    line, since a line starting with From may be the start of a new message
    in some mail/news archive and transport formats.
    Lars Enderin, Dec 9, 2006
    #6
  7. Lars Enderin wrote:
    > Andrew Thompson skrev:
    > > TNguyen wrote:
    > >> >From the perspective of a utility like top, would having a file open
    > >> and continuously write to it without closing it increase the memory
    > >> usage?

    > >
    > > Note: When I go to reply to your message, my software
    > > inserts a character before your text to indicate that I
    > > am 'quoting' your words, ..see the '>' above?
    > >
    > > The stray '>' at the beginning of your *original* message
    > > makes it appear that *you* were also quoting someone else!
    > >

    > Many mail and news agents will put a > in front of From if it starts a
    > line, since a line starting with From may be the start of a new message
    > in some mail/news archive and transport formats.


    It took me a few moments to realise the significance
    of what you were saying, since I'd forgotten the OP's
    use of the word 'From', and thought you were using it
    in a more generic sense.

    It would be interesting to find out if it was the news
    reader. ..oh wait a second, GG! OK.
    <http://groups.google.com/group/alt.test/browse_frm/thread/588afb7279a7b824/ec9393e87967e7fc>

    Proof you were right Lars, that post by me to alt.test,
    out of GG, had no leading '>' when I sent it.

    Andrew T.
    Andrew Thompson, Dec 9, 2006
    #7
  8. TNguyen

    Daniel Pitts Guest

    Andrew Thompson wrote:
    > TNguyen wrote:
    > > >From the perspective of a utility like top, would having a file open

    > > and continuously write to it without closing it increase the memory
    > > usage?


    > ( And no, I have no idea what 'top' is, nor its behaviour
    > with Java I/O streams. Yoo might clarify what it is, with
    > a link. )
    >
    > Andrew T.


    top is a standard Unix command which is similar to windows task
    manager. It displays memory and CPU statistics for running
    applications. I believe the OP is asking if continuously writing to a
    file will increase the apparent memory usage of a particular
    application.

    My short answer is, probably not. Although, the OS might cache
    some/all of the writes, and therefor allocate memory. Although,
    generally, if you are going to write to a file throughout the lifetime
    of an application (say for a log) then keeping the file open DOES make
    sense.
    Daniel Pitts, Dec 10, 2006
    #8
  9. TNguyen

    EJP Guest

    TNguyen wrote:

    >>From the perspective of a utility like top, would having a file open

    > and continuously write to it without closing it increase the memory
    > usage?


    If you are using an ObjectOutputStream, yes, otherwise no.
    EJP, Dec 10, 2006
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. metfan
    Replies:
    2
    Views:
    4,846
    Robert Olofsson
    Oct 21, 2003
  2. hvt
    Replies:
    0
    Views:
    1,206
  3. hvt
    Replies:
    0
    Views:
    1,463
  4. Krist
    Replies:
    8
    Views:
    6,422
    Arne Vajhøj
    Feb 10, 2010
  5. MrsEntity
    Replies:
    20
    Views:
    474
Loading...

Share This Page