Tags down


get size of DataTable or ArrayList in memory

By : Jari
Date : October 16 2020, 11:12 AM
This might help you You want to find out the size in memory of managed objects in code - according to this blog entry, it is not possible.
You need to use a memory profiler to do this (like the Ants profiler).
code :

Share : facebook icon twitter icon

What is the memory size of an ArrayList in Java

By : user2645817
Date : March 29 2020, 07:55 AM
around this issue You can use something like Runtime.getRuntime().totalMemory() and its counterpart Runtime.getRuntime().freeMemory() to get an educated guess, but that doesn't account for objects that are GC'ed between calls.

What is the maximum size of a DataTable I can load into memory in .Net?

By : user4712725
Date : March 29 2020, 07:55 AM
hope this fix your issue While I'm not sure of the memory footprint, there is a maximum number of rows. From MSDN:

VBA memory size of Arrays and Arraylist

By : john wayne
Date : March 29 2020, 07:55 AM
should help you out Most of the issue is the fact that VBA natively uses BSTRs, which are Unicode strings. I assume that your calculation of ~380 mb is based on 6 million * 64 characters @ 1 byte each. In actuality, the math works out to something like this:
code :
Option Explicit

Public Sub QuickSortInPlace(ByRef arrArray() As Variant)
    If UBound(arrArray) <= 1 Then
        Exit Sub
    End If
    qSort arrArray, 0, UBound(arrArray)
End Sub

Private Sub qSort(ByRef arrArray() As Variant, left As Long, right As Long)
    Dim pivot As Long
    Dim newPivotIndex As Long
    If left < right Then
        pivot = MedianOf3(arrArray, left, right)
        newPivotIndex = partition(arrArray, left, right, pivot)
        qSort arrArray, left, newPivotIndex - 1
        qSort arrArray, newPivotIndex + 1, right
    End If
End Sub

Private Function partition(ByRef arrArray() As Variant, left As Long, right As Long, pivot As Long) As Long
    Dim pivotValue As Variant
    pivotValue = arrArray(pivot)
    Swap arrArray, pivot, right
    Dim storeIndex As Long
    storeIndex = left
    Dim i As Long
    For i = left To right - 1
        If CompareFunc(arrArray(i), pivotValue) = -1 Then
            Swap arrArray, i, storeIndex
            storeIndex = storeIndex + 1
        End If
    Swap arrArray, storeIndex, right
    partition = storeIndex
End Function

Private Sub Swap(ByRef arrArray() As Variant, indexA As Long, indexB As Long)
    Dim temp As Variant
    temp = arrArray(indexA)
    arrArray(indexA) = arrArray(indexB)
    arrArray(indexB) = temp
End Sub

Private Function MedianOf3(ByRef arrArray() As Variant, left As Long, right As Long) As Long
    Dim a As Variant, b As Variant, c As Variant
    Dim indexA As Long, indexB As Long, indexC As Long
    Dim ab As Long
    Dim bc As Long
    Dim ac As Long
    indexA = left
    indexB = (left + right) \ 2
    indexC = right
    a = arrArray(indexA)
    b = arrArray(indexB)
    c = arrArray(indexC)

    ab = CompareFunc(a, b)
    bc = CompareFunc(b, c)
    ac = CompareFunc(a, c)

    If ab = -1 Then
        If ac = -1 Then
            If bc = -1 Or bc = 0 Then
                'a b c
                'Already in B
                'a c b
                Swap arrArray, indexB, indexC
            End If
            'c a b
            Swap arrArray, indexA, indexB
        End If
        If bc = -1 Then
            If ac = -1 Then
                'b a c
                Swap arrArray, indexA, indexB
                'b c a
                Swap arrArray, indexB, indexC
            End If
            'c b a
            'Already in B
        End If
    End If
    MedianOf3 = indexB
End Function

Private Function CompareFunc(str_a As Variant, str_b As Variant) As Long
    Dim a As Byte
    Dim b As Byte
    Dim i As Long

    For i = 0 To 63
        a = str_a(i)
        b = str_b(i)
        If a <> b Then
            Exit For
        End If
    If i <= 63 Then
        If a < b Then
            CompareFunc = -1
            CompareFunc = 1
        End If
        CompareFunc = 0
    End If

End Function
Option Explicit

Public Sub Main()
    Dim arrStrings() As Variant
    Dim i As Long

    'Get the strings from the file
    FillArrStringsInPlace arrStrings

    'Print the unsorted list
    Debug.Print "Unsorted Strings" & vbCrLf & "---------------------"
    For i = 0 To UBound(arrStrings)
        Debug.Print StrConv(arrStrings(i), vbUnicode)

    'Sort in place
    QuickSortInPlace arrStrings

    'Print the sorted list
    Debug.Print vbCrLf & vbCrLf & "Sorted Strings" & vbCrLf & "---------------------"
    For i = 0 To UBound(arrStrings)
        Debug.Print StrConv(arrStrings(i), vbUnicode)
End Sub

Public Sub FillArrStringsInPlace(ByRef arr() As Variant)
    Dim iFile As Integer
    Dim strInput As String
    Dim lineCount As Long
    Dim arrBytes() As Byte

    'Open a file in the same folder as this Access db called "data.txt"
    iFile = FreeFile
    Open ActiveWorkbook.Path & "\data.txt" For Input As iFile

    'Since I already know how many strings there are, I'm assigning it here.
    'The alternatives would be to either "dynamically resize" the array, which
    'is equivalent to copying the entire thing everytime you add a new string,
    'Or to count the number of newlines in the file and dimensioning the array
    'to that size before reading in the strings line by line.  Neither is as
    'efficient as just defining it before-hand.
    ReDim arr(0 To 7)

    While Not EOF(iFile)
        Line Input #iFile, strInput
        arrBytes = StrConv(strInput, vbFromUnicode)
        ReDim Preserve arrBytes(0 To 63)
        arr(lineCount) = arrBytes
        lineCount = lineCount + 1

    Close iFile
End Sub

Initial ArrayList size in Java dependent on memory?

By : user2514881
Date : March 29 2020, 07:55 AM
will be helpful for those in need The initial size of the ArrayList if the no-arg constructor is used quoting from the javadoc:
code :
public static int getCap(ArrayList<?> list) throws Exception {
    Field f = list.getClass().getDeclaredField("elementData");
    Object[] o = (Object[]) f.get(list);
    return o.length;
ArrayList<String> list = new ArrayList<>();
System.out.println(getCap(list));   // Prints 0

System.out.println(getCap(list));   // Prints 10

for (int i = 1; i < 11; i++)
System.out.println(getCap(list));   // Prints 15

for (int i = 11; i < 16; i++)
System.out.println(getCap(list));   // Prints 22

Are elements of ArrayList in Java reallocated in the memory when new ones are added If the size of the ArrayList has bee

By : Emmanuel Perotto
Date : March 29 2020, 07:55 AM
it helps some times To answer this, we can look directly at the source code of ArrayList#add. We first see the following method:
code :
public boolean add(E e) {
    add(e, elementData, size);
    return true;
private void add(E e, Object[] elementData, int s) {
    if (s == elementData.length)
        elementData = grow();
    elementData[s] = e;
    size = s + 1;
Related Posts Related Posts :
  • .NET Remoting client config creates local object, not remote
  • Is there a possibility to differ virtual printer from physical one?
  • Print barcode which has high scan rate
  • Query string value having "&"
  • Which is best for perfomance?
  • Can we make overloaded controller method in ASP .NET MVC
  • Nested loop in StringTemplate
  • How to get SSID and RSSI for Win7 using C#
  • Send messages to applications on the network (.Net)
  • Detect and prevent/delay windows mobile power off
  • How X509 Certificate renewal does not impact the code?
  • Silverlight: How to make my custom control act like a button
  • C# basic Dictionary Ordering Just need to clear an error
  • Common c# idioms including coalesce ?? operator
  • Why Does Thread.CurrentThread.CurrentCulture Change between Page Rendering and HttpModule.PostRequestHandlerExecute?
  • COM Exception 0x8004005
  • How do I show a message box from inside a class in a class library?
  • LINQ Distinct Query
  • Issue with number guessing game c#
  • Usage of a using statement
  • Building a forms system using DDD
  • How can I programmatically tell in C# if an unmanaged lib is x86 or x64?
  • How do I get an Excel range using row and column numbers in VSTO / C#?
  • .NET 4.0 Memory Mapped Files Performance
  • db4o Indexing problem - Not Working? Poor performance?
  • Realtime Console Output Redirection using Process
  • How do C# Linq extension methods perform equality comparison?
  • internal RSS feed not working with webClient object
  • C# / Silverlight / WPF / Fast rendering lots of circles
  • how to bind table from database to checkedListBox?
  • Is it ok to catch all exception types if you rethrow them wrapped another exception?
  • Print image in .Net winform
  • Problem with StandardOutput stream in async mode
  • Partially implement an Interface
  • How to extract html links from html file in C#?
  • Windows seems to lose track of .NET application
  • Do .NET 3/4 Permits Events to be Binary De/Serialized?
  • Static Methods in ASP.NET
  • How to set an Image fit to width of ScrollViewer
  • Can C# compiler be configured to give warning when explicit cast may cause data loss?
  • How can I strip html tags in C#
  • How do i unit test a website with no backend class?
  • Is there tool that can port or compile excel VBA code to C#?
  • NUnit conflict with Debug.Assert
  • C# Adding a long string to combobox
  • Creating Wizards for Windows Forms in C#
  • How to access the main windows handle once the child window exits in a process in C#
  • Mock AutoMapper Mapper.Map call using Moq
  • Copy C# object along with reference
  • Script for changing fonts in a Word document
  • 2 equal byte[] does not return true
  • Image capture of Windows mobile 5.0 camera using C# winform
  • Magento 1.4 productIdentifierType
  • File locks when using file.move in c#...how can I stop or fix this
  • Is there a framework that works the way like updating a virus definition database?
  • How can I make use of Visual Studio's regular expression to replace multiple lines of code?
  • Configuring Threadpool Max Threads via app.config?
  • C# thread dispatcher
  • Linkbutton inside Repeater for paging ASP.Net
  • How can I perform division in a program, digit by digit?
  • shadow
    Privacy Policy - Terms - Contact Us © bighow.org