Determine size of dynamically allocated memory in C

There is no standard way to find this information. However, some implementations provide functions like msize to do this. For example: _msize on Windows malloc_size on MacOS malloc_usable_size on systems with glibc Keep in mind though, that malloc will allocate a minimum of the size requested, so you should check if msize variant for your … Read more

change array size

You can use Array.Resize(), documented in MSDN. But yeah, I agree with Corey, if you need a dynamically sized data structure, we have Lists for that. Important: Array.Resize() doesn’t resize the array (the method name is misleading), it creates a new array and only replaces the reference you passed to the method. An example: var … Read more

Calculating usage of localStorage space

You may be able to get an approximate idea by using the JSON methods to turn the whole localStorage object to a JSON string: JSON.stringify(localStorage).length I don’t know how byte-accurate it would be, especially with the few bytes of added markup if you’re using additional objects – but I figure it’s better than thinking you’re … Read more

Maximum size of a PHP session

You can store as much data as you like within in sessions. All sessions are stored on the server. The only limits you can reach is the maximum memory a script can consume at one time, which by default is 128MB. (Similar answers: Ideal PHP Session Size? – some useful comments)

Java JTable setting Column Width

What happens if you call setMinWidth(400) on the last column instead of setPreferredWidth(400)? In the JavaDoc for JTable, read the docs for doLayout() very carefully. Here are some choice bits: When the method is called as a result of the resizing of an enclosing window, the resizingColumn is null. This means that resizing has taken … Read more

Determine the size of an InputStream

This is a REALLY old thread, but it was still the first thing to pop up when I googled the issue. So I just wanted to add this: InputStream inputStream = conn.getInputStream(); int length = inputStream.available(); Worked for me. And MUCH simpler than the other answers here. Warning This solution does not provide reliable results … Read more