heap-memory

Value types in object stored in heap as well?

狂风中的少年 提交于 2020-01-11 05:12:05
问题 I can imagine this question has been asked thousands of times, but I didn't have much luck in finding the answer, plus this is more out of curiosity than need. Digging into the nuts and bolts of C#, I was wondering since objects are stored in the heap, are the value types within the objects stored in the heap as well or are they placed in the stack? 回答1: They are stored in the heap, inside of the memory allocated for the reference type. In addition, value types are often stored in places

memory allocation in Stack and Heap

℡╲_俬逩灬. 提交于 2020-01-10 07:58:14
问题 This may seem like a very basic question, but its been in my head so: When we allocate a local variable, it goes into stack. Similarly dynamic allocation cause the variable to go on heap. Now, my question is, is this variable actually lie on stack or heap or we will just a reference in the stack and Heap. For example, Suppose I declare a variable int i . Now this i is allocated on the stack. So, when I print the address of i , this will be one of the location on stack? Same question for heap

Java TCP Socket Byte Heap Memory Issue

拈花ヽ惹草 提交于 2020-01-06 19:35:50
问题 I have a Java TCP Server Socket program that is expecting about 64 bytes of data from a piece of remote hardware. The Server code is: public void run () throws Exception { //Open a socket on localhost at port 11111 ServerSocket welcomeSocket = new ServerSocket(11111); while(true) { //Open and Accept on Socket Socket connectionSocket = welcomeSocket.accept(); DataInputStream dIn = new DataInputStream(connectionSocket.getInputStream()); int msgLen = dIn.readInt(); System.out.println("RX

How to increase Tomcat Heap memory on windows

£可爱£侵袭症+ 提交于 2020-01-06 04:37:08
问题 I read many posts on the internet and here on stackoverflow, but I'm still not able to increase Tomcat Heap Siz e. Probably I made an error that I can't recognize. Following this guide I did these steps: I created the file setenv.bat inside the folder {tomcat}\bin Inside the file setenv.bat I added the string set "JAVA_OPTS=%JAVA_OPTS% -Xms128m -Xmx1024m -XX:MaxPermSize=512m -server" When I run Tomcat and then I launch my app (for instance localhost:8080/appName) and I try to know the heap

Can you please explain this C++ delete problem?

本秂侑毒 提交于 2020-01-04 09:10:35
问题 I have the following code: std::string F() { WideString ws = GetMyWideString(); std::string ret; StringUtils::ConvertWideStringToUTF8(ws, ret); return ret; } WideString is a third-party class, so are StringUtils. They are a blackbox to me. Second parameter is passed by reference. When I step through the debugger the line return ret throws a nasty popup (Visual C++) saying that heap may be corrupted. Upon closer examination copy of the string that gets returned is OK, but the deletion of ret

Iterating through a vector of stucts's members with pointers and offsets

自作多情 提交于 2020-01-03 20:56:56
问题 I am trying to optimize a piece of code by not pointer chasing, as much as I currently am. I want to create a constant offset to add to a stored pointer to get to the next data entry, see below code. However, the data is sitting side a class or struct, containing different data types. So I get the correct behavior in the below code snippet, ie the output is 1, 2, 3. #include <iostream> #include <vector> // knows nothing about foo class Readfoo { private: int offset; double* pdouble; public:

Should I delete pointers that come from other functions or class methods?

杀马特。学长 韩版系。学妹 提交于 2020-01-03 03:27:07
问题 I have a background in Java and I'm still not fully used to the concept of pointers and scope, so sorry if the question seems silly. I read somewhere that I should delete pointers that I have allocated on the Heap. I understand that but should I also delete a pointer that is given to me like this: #include<dirent.h> DIR* dir; struct dirent* entries; dir= opendir("D:/DIR") entries= readdir(entries) // Should I delete the pointers after I'm done with them? delete entries; delete dir; Should I

heap usage for CPS vs non-CPS parsers in Haskell's parsec

試著忘記壹切 提交于 2020-01-02 13:56:25
问题 I'm trying to write the following parser using parsec: manyLength :: forall s u m a. Monad m => ParsecT s u m a -> ParsecT s u m Int manyLength p = go 0 where go :: Int -> ParsecT s u m Int go !i = (p *> go (i + 1)) <|> pure i This is like the many function, but instead of returning [a] , it returns the number of times Parser a succeeds. This works, but I can't seem to make it run in constant heap space. This makes sense, since the recursive call to go is not in the tail-call position. If

Address of a Global Variable in the Heap Address Range

假装没事ソ 提交于 2020-01-02 10:22:21
问题 I was debugging the MPlayer-1.3.0 source code, and I saw a global variable whose address (returned by GDB or even simple printing) was in the range for the heap allocations, instead of the data section. I checked the heap range using procfs . 555555554000-555555834000 r-xp 00000000 08:12 798876 /usr/bin/mplayer 555555a33000-555555b25000 r--p 002df000 08:12 798876 /usr/bin/mplayer 555555b25000-555555b2b000 rw-p 003d1000 08:12 798876 /usr/bin/mplayer 555555b2b000-555556479000 rw-p 00000000 00

google common cache - default value of maximumSize (and other “optional” settings) - want a cache that uses all “available” memory

为君一笑 提交于 2020-01-02 08:35:48
问题 I just found Guava by searching for a cache API (it fits perfectly for my needs). But one question arose on reading the wiki and Javadoc - what are the default values of settings the CacheBuilder can take? The Javadoc states "These features are all optional" and "Constructs a new CacheBuilder instance with default settings, including strong keys, strong values, and no automatic eviction of any kind." In my opinion, a good default for maximumSize would be relative to Runtime.getRuntime()