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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:30:43+00:00 2026-06-18T08:30:43+00:00

I need to work with some databases read with read.table from csv (comma separated

  • 0

I need to work with some databases read with read.table from csv (comma separated values ), and I wish to know how to compute the size of the allocated memory for each type of variable.

How to do it ?

edit — in other words : how much memory R allocs for a general data frame read from a .csv file ?

  • 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-06-18T08:30:44+00:00Added an answer on June 18, 2026 at 8:30 am

    You can get the amount of memory allocated to an object with object.size. For example:

    x = 1:1000
    object.size(x)
    # 4040 bytes
    

    This script might also be helpful- it lets you view or graph the amount of memory used by all of your current objects.

    In answer to your question of why object.size(4) is 48 bytes, the reason is that there is some overhead in each numeric vector. (In R, the number 4 is not just an integer as in other languages- it is a numeric vector of length 1). But that doesn’t hurt performance, because the overhead does not increase with the size of the vector. If you try:

    > object.size(1:100000) / 100000
    4.0004 bytes
    

    This shows you that each integer itself requires only 4 bytes (as you expect).

    Thus, summary:

    • For a numeric vector of length n, the size in bytes is typically 40 + 8 * floor(n / 2). However, on my version of R and OS there is a single slight discontinuity, where it jumps to 168 bytes faster than you would expect (see plot below). Beyond that, the linear relationship holds, even up to a vector of length 10000000.

      plot(sapply(1:50, function(n) object.size(1:n)))
      

    enter image description here

    • For a categorical variable, you can see a very similar linear trend, though with a bit more overhead (see below). Outside of a few slight discontinuities, the relationship is quite close to 400 + 60 * n.

      plot(sapply(1:100, function(n) object.size(factor(1:n))))
      

    enter image description here

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

Sidebar

Related Questions

For some graphics work I need to read in a large amount of data
I'm doing some work with registry hives, and I need to know if the
I need to read some data from database my controller is class Pro_ajax extends
I need to work with some old C++ code that was developed in Visual
That title may need some work. Perhaps after reading this, you may be able
I need a fresh temporary directory to do some work in a shell script.
So for some research work, I need to analyze a ton of raw movement
Using C#, I need to do some extra work if function A() was called
I need some help with a work project I have been assigned. At the
I need some recommendations how to work better with the same sprites using Cocos2d.

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.