memory

Memory Stream in Java

笑着哭i 提交于 2021-02-05 13:12:24
问题 I am looking for a memory stream implementation in Java. The implementation should be roughly modeled after the .NET memory stream implementation. Basically I would like to have a class MemoryStream which has to factory methods: class MemoryStream { MemoryInput createInput(); MemoryOutput createOutput(); } class MemoryInput extends InputStream { long position(); void seek(long pos); } class MemoryOutput extends OutputStream { long position(); void seek(long pos); } So once I have an instance

Memory Stream in Java

夙愿已清 提交于 2021-02-05 13:10:10
问题 I am looking for a memory stream implementation in Java. The implementation should be roughly modeled after the .NET memory stream implementation. Basically I would like to have a class MemoryStream which has to factory methods: class MemoryStream { MemoryInput createInput(); MemoryOutput createOutput(); } class MemoryInput extends InputStream { long position(); void seek(long pos); } class MemoryOutput extends OutputStream { long position(); void seek(long pos); } So once I have an instance

How to load (or map) file part maximum size, but fit in RAM on Windows?

冷暖自知 提交于 2021-02-05 12:21:02
问题 There is big file. I need fast sort it. I going to process the file by part, that fit in RAM, to avoid/degrees using page file (next step: merge parts). How to use max RAM? My solution: use WinApi file memory mapping, but I don't knew how to get part of file maximum size, but fit RAM (how to determine size)? 回答1: You can VirtualLock the pages you want to process. It locks in physical memory the size you need (if there is enough) swapping others to the paging file. You can use the

Why does allocated memory is different than the size of the string?

拜拜、爱过 提交于 2021-02-05 12:20:50
问题 Please consider the following code: char **ptr; str = malloc(sizeof(char *) * 3); // Allocates enough memory for 3 char pointers str[0] = malloc(sizeof(char) * 24); str[1] = malloc(sizeof(char) * 25); str[2] = malloc(sizeof(char) * 25); When I use some printf to print the memory adresses of each pointer: printf("str[0] = '%p'\nstr[1] = '%p'\nstr[2] = '%p'\n", str[0], str[1], str[2]); I get this output: str[0] = '0x1254030' str[1] = '0x1254050' str[2] = '0x1254080' I expected the number

How to display picture from memory in Django?

只愿长相守 提交于 2021-02-05 11:23:08
问题 I know how to show picture as a page from memory just using like this: import cStringIO mStream = cStringIO.StringIO(picBin) return HttpResponse(mStream.getvalue(),"image/jpg") But what if I don't want to show the picture as a page, instead I want to show it within a page, say using in HTML, does someone has an idea what I should set the "src" if the picture is loaded from memory? 回答1: You'll need to base-64 encode the image contents into a Data URI: data_uri = 'data:image/jpg;base64,' data

Memory Access using 32 bit address in a word-addressable system

。_饼干妹妹 提交于 2021-02-05 11:18:05
问题 I'm just checking to make sure I have a proper understanding of how memory access works. Say I have a word-addressable memory system with 64-bit words. How much memory could be accessed using a 32-bit address size? A 64 bit word is 8 bytes, so we're dealing with an 8 byte word. An 8 byte word can hold up to 2^8 (256). Given that we have a 32 bit address, we have 2^32, but since each word is taking up 256 of those, (2^32)/256 = 1677216 bytes. To put that into metric terms, we have 2^24 = (2^4)

Memory leak, does window have a safeguard to prevent max memory reached?

淺唱寂寞╮ 提交于 2021-02-05 08:22:27
问题 I have an application that uses a 3rd party API and I think they are having a memory leak issue. I wrote a small test program (below) to test this out, please note, both VMIListener and VMI are from the APIs in which I'm implementing their virtual interface methods. I don't have any memory leak behavior if I comment out the VMI vmi; under my VMITest class. With my limited knowledge in C++ I assume this is because the virtual VMI class does not have the virtual destructor. However, my question

How does x86 handle byte vs word addressing when executing instructions and reading/writing data?

人盡茶涼 提交于 2021-02-05 08:21:45
问题 So I am learning how x86 works and have come across people saying that it is byte-addressable, yet can read words, double words, etc. How does the processor decide which method to use and when? E.g. for accessing the next instruction and when a user wants to read/write to memory, which addressing mode is used? 回答1: Every memory access has an operand-size specified by the machine-code instruction. (Addressing mode isn't the right term: different addressing modes are different ways of

Making Sieve of Eratosthenes more memory efficient in python?

╄→гoц情女王★ 提交于 2021-02-05 05:32:28
问题 Sieve of Eratosthenes memory constraint issue Im currently trying to implement a version of the sieve of eratosthenes for a Kattis problem, however, I am running into some memory constraints that my implementation wont pass. Here is a link to the problem statement. In short the problem wants me to first return the amount of primes less or equal to n and then solve for a certain number of queries if a number i is a prime or not. There is a constraint of 50 MB memory usage as well as only using

Why the operating system says it can't allocate memory to jvm when it has enough memory

╄→гoц情女王★ 提交于 2021-02-05 05:31:30
问题 I'm trying to start a new jvm with the command: java -version , but it report a error: # There is insufficient memory for the Java Runtime Environment to continue. # Native memory allocation (malloc) failed to allocate 160088 bytes for AllocateHeap # An error report file with more information is saved as: # /users/xxx/xxx/hs_err_pid12365.log Then I checked file /users/xxx/xxx/hs_err_pid12365.log , and I find out it say: # Native memory allocation (malloc) failed to allocate 295856 bytes for